You must check for the end of file after every read operation. Normally, you would use EOF statement for this. However, this statement is broken in v1.6.x As a workround you can try v2.0 beta (free download available now) or Read the entire using FileReadAll the use GetToken in a loop to extract lines one by one

: The problem i'm having is that it keeps reading from the file, even though it : reaches the end of it. Any ideas? Code included.

: You must check for the end of file after every read operation. Normally, you : would use EOF statement for this. However, this statement is broken in : v1.6.x : As a workround you can try v2.0 beta (free download available now) or : Read the entire using FileReadAll the use GetToken in a loop to extract lines : one by one

Fri Feb 04, 2000 11:37 am

SysOpSite Admin

Joined: 26 Nov 2006Posts: 6571

Re: Loop Problems

The script you posted earlier today is structurally (logically) incorrect, which leads you to troubles.

Here is how you can change it (note that in the version v2.0 such script can be much more elegant since that version supports nested loops)

{ … bunch of Dim here …} {… File open here …. }

EOF(file_number, end_of_file) LOOPUNTIL (end_of_file, END_LOOP_LABEL)

FILEREAD file_number, webserver

{A whole bunch of concats}

RUNANDWAIT command_map, "c:\bin", 20, process_id

// reset counter

SET counter, 0

// make 3 attempts to find that file

RUN_POOL:

ADD counter, 1, counter

ISGREATER counter, 3, pool_fail

IFTHEN pool_fail, WRITE_ERROR

FILEEXISTS command, END_POOL_LOOP

// Wait 1 second then try again

WAIT 1 END_POOL_CHECK:

// file found so run the command

RUNANDWAIT command4, "C:\bin",0, process_id

GOTO GET_NEXT_LINE

WRITE_ERROR:

// file not found after 3 attempts

RUNANDWAIT(command_touch, "C:\bin", 20, process_id)

Concat (pull_error, webserver, pull_error1)

FileWrite(out, pull_error1)

GET_NEXT_LINE:

RUN_PULL: EOF(file_number, end_of_file) END_LOOP_LABEL

FileClose( file_number ) FileClose( out )

: Thats a pretty bogus feature/bug. Considering i try the workaround, what am i : supposed to loop on with the gettoken command. Can't very well loop on : EOF.