Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A musical note from QuickBASIC with XP?
#11
Yes, Tyler, a professional has to keep up with the latest developements, he has to remain on, or near, the cutting edge of programming. We mere amateurs simply keep on using the same old programs we started and learned with, unless we are compelled to use and learn newer ones, as happens when we are employed by progressive firms.

I'm not saying that there aren't professionals out there who still are able to live, using the old programs, but, the great majority will be using much more advanced programs, that allow very powerful results!

To us, trying to keep up with the newer programs would be so time and money consuming, that we just stay put! After all, we really don't have to go through all that pain and trouble, only to have to buy and learn yet another new program or language, time after time! But, a professional is in that situation very frequently, and knows that he just has to be on the ball with most every new thing that hits the market, or lose out.
Ralph, using QuickBASIC 4.5 and Windows XP Home Edition and Service Pack 2, with HP LaserJet 4L printer.
Reply
#12
Just fyi, I did some testing when I used QB. I made a simple test that ran a FOR...NEXT against DO...LOOP. FOR...NEXT won the match. I never did test WHILE...WEND though. Wink
Reply
#13
Hey, Dr, why not test the While/Wend now? And, what was your test all about? What did you prove?
Ralph, using QuickBASIC 4.5 and Windows XP Home Edition and Service Pack 2, with HP LaserJet 4L printer.
Reply
#14
Oh... Well, I don't have QB anymore, so I can't test it now. The original test was a speed comparison though. Wink
Reply
#15
I forget what the statement is to get the no of milliseconds after midnight, but you would do something like this:

Code:
oldtime$ = no_of_milliseconds$
   for x = 1 to 100: next x
   newtime$ = no_of_milliseconds$
   print "FOR-NEXT took "; newtime$; " milliseconds."

Then repeat for Do-Loop and While-Wend.
In the beginning, there is darkness – the emptiness of a matrix waiting for the light. Then a single photon flares into existence. Then another. Soon, thousands more. Optronic pathways connect, subroutines emerge from the chaos, and a holographic consciousness is born." -The Doctor
Reply
#16
Dr and Skyler:

I made this loop-timing program:
Code:
'LoopTime times various loops in QuickBASIC

CLS

n# = 10000000
PRINT
A$ = "Comparison of average times in 10 loops of three loop-times in QuickBASIC 4.5"
PRINT SPC(40 - LEN(A$) / 2); A$
PRINT
PRINT "                 T I M E    I N    S E C O N D S "
PRINT "               ----------------------------------"
PRINT "  Iter. No.     FOR/NEXT    DO/LOOP    WHILE/WEND"
PRINT "  ---------    ----------  ----------  ----------"

FOR J = 1 TO 10
  LOCATE 7 + J, 8: PRINT J

  'FOR/NEXT
  t0 = TIMER
  FOR i = 1 TO n#
    xx = xx + 1
  NEXT i
  tf = TIMER
  tfn = tfn + tf - t0
  LOCATE 7 + J, 16: PRINT tfn / J

  'DO/LOOP
  i = 0
  t0 = TIMER
  DO WHILE i < n#
    i = i + 1
  LOOP
  tf = TIMER
  tdl = tdl + tf - t0
  LOCATE 7 + J, 16 + 12: PRINT tdl / J

  'WHILE/WEND
  i = 0
  t0 = TIMER
  WHILE i < n#
    i = i + 1
  WEND
  tf = TIMER
  tww = tww + tf - t0
  LOCATE 7 + J, 16 + 24: PRINT tww / J

NEXT J

These are the answers for the 10th iteration:
FOR/NEXT = 5.829 secs
DO/LOOP = 5.930 secs
WHILE/WEND = 5.966 secs

As can be seen, all took the same time, 6 seconds, practically speaking.

If I take out the unnecessary line, "xx = xx + 1", that I stuck in the FOR/NEXT loop to "equalize" it to the other two loops, its time drops, dramatically, to around 3 seconds. It would seem that each line takes 3 seconds to execute.

Comments?
Ralph, using QuickBASIC 4.5 and Windows XP Home Edition and Service Pack 2, with HP LaserJet 4L printer.
Reply
#17
So... use FOR-NEXT?
In the beginning, there is darkness – the emptiness of a matrix waiting for the light. Then a single photon flares into existence. Then another. Soon, thousands more. Optronic pathways connect, subroutines emerge from the chaos, and a holographic consciousness is born." -The Doctor
Reply
#18
By adding the xx=xx+1 in the For...Next loop, you're making it work twice as hard as the others. It's already counting, where the others aren't, ya know? Wink
Reply
#19
Comparing the for-next to the while-wend and do-loop isn't really fair. They're designed for different things. It's like comparing apples to oranges, by painting the apples orange.
In the beginning, there is darkness – the emptiness of a matrix waiting for the light. Then a single photon flares into existence. Then another. Soon, thousands more. Optronic pathways connect, subroutines emerge from the chaos, and a holographic consciousness is born." -The Doctor
Reply
#20
Quote:Comparing the for-next to the while-wend and do-loop isn't really fair. They're designed for different things. It's like comparing apples to oranges, by painting the apples orange.

True, but by all means, use For...Next whenever possible.

For instance...

If you wish to loop through each element of an array:

Code:
For i = Lbound(Array) To Ubound(Array)
    Print Array(i)
Next

For...Next will always win in such case. Wink

And for God's sake, don't paint your apples orange!!! :rotfl:
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)