Here is another bug involving IF-ELSE-ENDIF ... this one related to the
IfFileExists statement. Try using the Debugger to step through this code:
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
label>FindStatus
IfFileExists>c:\testfile.txt
Let>FileStat=File Exists
else
Let>FileStat=File Doesn't Exist
endif
label>Loop
let>x=1
if>x=1,FindStatus,Loop
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
You'll see that program executes correctly during the FIRST pass only.
On subsequent passes, the IfFileExists statement behaves as
a SubRoutine call.... and doesn't execute the IF-ELSE logic at all.
Bug in IfFileExists... If-Else logic
Moderators: JRL, Dorian (MJT support)
Hi,
The problem is due to the mix of old and new IF syntax. This version works:
/////////////////////
label>FindStatus
IfFileExists>c:\testfile.txt
Let>FileStat=File Exists
else
Let>FileStat=File Doesn't Exist
endif
label>Loop
let>x=1
if>x=1
Goto>FindStatus
else
Goto>Loop
EndIf
/////////////////////
I'll look into either whether we can ensure old and new syntax works better together, or failing that at least make the documentation clear that it is best to use either one or the other.
The problem is due to the mix of old and new IF syntax. This version works:
/////////////////////
label>FindStatus
IfFileExists>c:\testfile.txt
Let>FileStat=File Exists
else
Let>FileStat=File Doesn't Exist
endif
label>Loop
let>x=1
if>x=1
Goto>FindStatus
else
Goto>Loop
EndIf
/////////////////////
I'll look into either whether we can ensure old and new syntax works better together, or failing that at least make the documentation clear that it is best to use either one or the other.
MJT Net Support
[email protected]
[email protected]
Mixing Old and New?
The example I posted represents two completely different IF statements.
In my actual program, the similar statements were separated by nearly two hundred lines of code... they weren't "mixed" at all.
Additionally, the behavior of the IfFileExists logic varies.... when the file actually does exist, program flow is as it should be. The variant
behavior occurs when the file doesn't exist..... resulting in a
"return from subroutine" behavior..... that skips both the TRUE and FALSE
logic of the IF-ELSE-ENDIF structure.
Blessings,
Waldo
In my actual program, the similar statements were separated by nearly two hundred lines of code... they weren't "mixed" at all.
Additionally, the behavior of the IfFileExists logic varies.... when the file actually does exist, program flow is as it should be. The variant
behavior occurs when the file doesn't exist..... resulting in a
"return from subroutine" behavior..... that skips both the TRUE and FALSE
logic of the IF-ELSE-ENDIF structure.
Blessings,
Waldo
I've tested the above script with both an existing and non-existing file and it worked correctly.
MJT Net Support
[email protected]
[email protected]
Just to let you know we have found the cause of this problem (see first post above) and have fixed it. The fix will be in 7.3.08 which should hopefully be available later today.
MJT Net Support
[email protected]
[email protected]