Project

General

Profile

Actions

Bug #1150

closed

if exist () no longer works with either True or False or !=True or !=False on the end

Added by malcolm harvey over 1 year ago. Updated 8 months ago.

Status:
Closed
Priority:
Normal
Target version:
Start date:
06/06/2023
Due date:
% Done:

0%

Estimated time:
Affected version:

Description

This was also connected to bug 976 a similar issue from the past.
It seams in that ticket, we had to add = True to get it to work where again previously no true or false was required after if exists() Later in U38 we had to add !=True or !=False to get it to work. But now below this has broken again....
..
This ticket below again now in U44...Seams True or False or !=True or !=False does not work.
.
(The below issues now with if exist() inst/func in U44).
re: Checking file in browser local storage now if exists.
The 4 variations one can use, but none work currently now.
Again yes, something has changed here from after ver U38
last time I ever got this or these options to work correctly.
.
//This version always thinks it does exist
//but never creates anything....(Incorrect)
//Should go to else once until true.
..
a)
main:
If exist("myfile.txt")!=False //if true

print "file exists"
Wait Key
goto done

else
Open Out 1,"myfile.txt"
Print #1,0
Close 1
Print "file not there, create one"
wait key
goto done
End If

done:
goto main


//This version always thinks it does exist
//and creates it constantly. (Incorrect)
//Should go to else second time around.
..
b)
main:
If exist("myfile.txt")!=True //not true

Open Out 1,"myfile.txt"
Print #1,0
Close 1
Print "file not there, create one"
wait key
goto done

else
print "file exists"
Wait Key
goto done
End If

done:
goto main


//This version always thinks it does not exist
//and creates it constantly . (Incorrect)
//Should to to else once then always exists.
..
c)
main:
If exist("myfile.txt")=True //is true

print "file exists"
Wait Key
goto done

else
Open Out 1,"myfile.txt"
Print #1,0
Close 1
Print "file not there, create one"
wait key
goto done
End If

done:
goto main


//This version always thinks it does not exist
//and never creates it. (Incorrect)
//Should go to else after first write and loop.
..
d)
main:
If exist("myfile.txt")=False //is false

Open Out 1,"myfile.txt"
Print #1,0
Close 1
Print "file not there, create one"
wait key
goto done

else
print "file exists"
Wait Key
goto done
End If

done:
goto main

Note: As above, long long long ago in aoz, we could simply do the below.
One day that changed, this was many moons ago in early betas.
eg: No True or False to worry about. Brian also saw and noted that early on as well.
if exist("filename.txt")
//then it would do whatever was here under it (True)
else
//then do whatever was here under it if (false)
end if

Actions

Also available in: Atom PDF