SoftTree Technologies SoftTree Technologies
Technical Support Forums
RegisterSearchFAQMemberlistUsergroupsLog in
Loop Problems

 
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite View previous topic
View next topic
Loop Problems
Author Message
Tom Smit



Joined: 26 Jan 2000
Posts: 21

Post Loop Problems Reply with quote

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.

LOOPUNTIL (end_of_file, END_LOOP)
BEGIN_LOOP:

FILEREAD (file_number, webserver)

{A whole bunch of concats}

RunAndWait(command_map, "c:\bin", 20, process_id)

FileExists(command, found)

IFTHEN(found, RUN_PULL)

WAIT(1)

FILEEXISTS(command, found)

IFTHEN(found, RUN_PULL)

WAIT(1)

FILEEXISTS(command, found)

IFTHEN(found, RUN_PULL)

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

Concat (pull_error, webserver, pull_error1)

FileWrite(out, pull_error1)

goto BEGIN_LOOP
RUN_PULL:

RunAndWait( command4, "C:\bin",0, process_id)
END_LOOP:
FileClose( file_number )
FileClose( out )
EXIT

Fri Feb 04, 2000 10:23 am View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7839

Post Re: Loop Problems Reply with quote

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.

: LOOPUNTIL (end_of_file, END_LOOP)
: BEGIN_LOOP: FILEREAD (file_number, webserver)

: {A whole bunch of concats}

: RunAndWait(command_map, "c:\bin", 20, process_id)

: FileExists(command, found)

: IFTHEN(found, RUN_PULL)

: WAIT(1)

: FILEEXISTS(command, found)

: IFTHEN(found, RUN_PULL)

: WAIT(1)

: FILEEXISTS(command, found)

: IFTHEN(found, RUN_PULL)

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

: Concat (pull_error, webserver, pull_error1)

: FileWrite(out, pull_error1)

: goto BEGIN_LOOP
: RUN_PULL: RunAndWait( command4, "C:\bin",0, process_id)
: END_LOOP: FileClose( file_number )
: FileClose( out )
: EXIT

Fri Feb 04, 2000 11:08 am View user's profile Send private message
Tom Smit



Joined: 26 Jan 2000
Posts: 21

Post Re: Loop Problems Reply with quote

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.

I downloaded BETA2 by the way, 1 liscense, no remote agents...thats pretty bogus too.

: 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 View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7839

Post Re: Loop Problems Reply with quote

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.

: I downloaded BETA2 by the way, 1 liscense, no remote agents...thats pretty
: bogus too.

Fri Feb 04, 2000 1:35 pm View user's profile Send private message
SysOp
Site Admin


Joined: 26 Nov 2006
Posts: 7839

Post Re: Loop Problems Reply with quote

Sorry, it was my mistake. You should remove second "RUN_PULL" label from my script

: 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.

: I downloaded BETA2 by the way, 1 liscense, no remote agents...thats pretty
: bogus too.

Fri Feb 04, 2000 1:38 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    SoftTree Technologies Forum Index » 24x7 Scheduler, Event Server, Automation Suite All times are GMT - 4 Hours
Page 1 of 1

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


 

 

Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.