Check that file exists: Difference between revisions
Content added Content deleted
(Add QB64) |
(Added solution for Action!) |
||
Line 137: | Line 137: | ||
.include "../includeARM64.inc" |
.include "../includeARM64.inc" |
||
</lang> |
</lang> |
||
=={{header|Action!}}== |
|||
<lang Action!>BYTE lastError |
|||
PROC MyError(BYTE errCode) |
|||
lastError=errCode |
|||
RETURN |
|||
BYTE FUNC FileExists(CHAR ARRAY fname) |
|||
CARD old |
|||
BYTE dev=[1] |
|||
lastError=0 |
|||
old=Error |
|||
Error=MyError ;replace error handling to capture I/O error |
|||
Close(dev) |
|||
Open(dev,fname,4) |
|||
Close(dev) |
|||
Error=old ;restore the original error handling |
|||
IF lastError=0 THEN |
|||
RETURN (1) |
|||
FI |
|||
RETURN (0) |
|||
PROC Test(CHAR ARRAY fname) |
|||
BYTE exists |
|||
exists=FileExists(fname) |
|||
IF exists THEN |
|||
PrintF("File ""%S"" exists.%E",fname) |
|||
ELSE |
|||
PrintF("File ""%S"" does not exist.%E",fname) |
|||
FI |
|||
RETURN |
|||
PROC Main() |
|||
Test("D:INPUT.TXT") |
|||
Test("D:DOS.SYS") |
|||
RETURN</lang> |
|||
{{out}} |
|||
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Check_that_file_exists.png Screenshot from Atari 8-bit computer] |
|||
<pre> |
|||
File "D:INPUT.TXT" does not exist. |
|||
File "D:DOS.SYS" exists. |
|||
</pre> |
|||
=={{header|Ada}}== |
=={{header|Ada}}== |