Timer

Discussion in 'Computer Science & Culture' started by Spectrum, Jan 28, 2011.

Thread Status:
Not open for further replies.
  1. Spectrum Registered Senior Member

    Messages:
    459
    The following is a timer written in qbasic (Windows 98/tools/oldmsdos). It continues to performs a counting operation while it remains the same second as when it began the process. The results are then printed to the screen as a percentage and then raw data (but you can use a file (or both)). However the largest number it should be able to achieve here is 255 (8 bits) and for that to be (almost) true then each c% should be printed to the screen. As the code stands the percentages are (usually) higher than one hundred.

    Code:
    'TimeReset
    2 a%=val(mid$(time$,8,1))
    b%=val(mid$(time$,8,1))
    while b%=a%
    b%=val(mid$(time$,8,1))
    wend
    'TimeSet
    a%=val(mid$(time$,8,1))
    b%=val(mid$(time$,8,1))
    while b%=a%
    b%=val(mid$(time$,8,1))
    c%=c%+1
    wend
    p%=(c%/256)*100
    print date$;" ";time$;" ";p%;"% ";c%
    goto 2
    
    Now all I need to do is write a code that allows this to run in the baground while other programs are running...
     
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. Chipz Banned Banned

    Messages:
    838
    I am going to show you a nifty little trick.

    Code:
    'TimeReset
    2 
        a%=val(mid$(time$,8,1))
        b%=val(mid$(time$,8,1))
    
        while b%=a%
            b%=val(mid$(time$,8,1))
        wend
    
    'TimeSet
        a%=val(mid$(time$,8,1))
        b%=val(mid$(time$,8,1))
    
        while b%=a%
            b%=val(mid$(time$,8,1))
            c%=c%+1
        wend
    
        p%=(c%/256)*100
    
        print date$;" ";time$;" ";p%;"% ";c%
    
    goto 2
    WOW! LOOK AT THAT!! YOU CAN READ IT!!!

    But seriously, I wave to ask. Why on earth are you using Qbasic? It's one of the most antiquated and worthless languages barely in existence.
     
  4. Google AdSense Guest Advertisement



    to hide all adverts.
  5. Spectrum Registered Senior Member

    Messages:
    459
    Well it's good enough to produce random numbers and it seems to have everything I need.

    Please Register or Log in to view the hidden image!



    Oh yeah, I missed c%=0 before the incrementation loop.
     
  6. Google AdSense Guest Advertisement



    to hide all adverts.
  7. txrex Registered Member

    Messages:
    25
    Thanks chipz, I was thinking of doing that as I was reading.... then I scrolled down

    Please Register or Log in to view the hidden image!

     
  8. Chipz Banned Banned

    Messages:
    838
    You will never be hired as a programmer.
     
  9. Giambattista sssssssssssssssssssssssss sssss Valued Senior Member

    Messages:
    4,878
    I got no clue what yall is talking bout, but if I had money, I'd hire that person in a heartbeat!

    A charitable heartbeat.
     
Thread Status:
Not open for further replies.

Share This Page