April 30, 2024, 01:09:29 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Read strings from file

Started by aurelCB, August 11, 2009, 05:46:41 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

aurelCB

August 11, 2009, 05:46:41 AM Last Edit: March 04, 2023, 02:45:08 AM by aurelCB
Hi...

ZeroDog

QuoteIs faster way use WHILE/ENDWILE loop instead DO/UNTIL ?

They should be about the same.  I think the difference between the two is that with a DO/UNTIL loop it checks the conditional flag of the loop EOF(file1) at the end of the loop, and the WHILE/ENDWHILE checks the conditional flag at the start of the loop. 

You could always time how long each loop takes using the GetTickCount API function.


DECLARE "kernel32.dll", GetTickCount(),int

TicksBeforeLoop=GetTickCount()
Do
  'read contents of file here
Until EOF(file1)
TicksAfterLoop=GetTickCount()
MillisecondsItTookForLoop=TicksAfterLoop-TicksBeforeLoop




ZeroDog

if you time one cycle of the while loop, is it 10 milliseconds?

Ionic Wind Support Team

GetTickCount only has a resolution of 10ms, so it's not very useful for timing one iteration of code.  Run 1000 iterations of each.
Ionic Wind Support Team