Check that file exists: Difference between revisions

Content added Content deleted
m (Improved grammar in comments.)
Line 1,377: Line 1,377:
=={{header|Forth}}==
=={{header|Forth}}==


<syntaxhighlight lang="forth">: .exists ( str len -- ) 2dup file-status nip 0= if ." exists" else ." does not exist" then type ;
<syntaxhighlight lang="forth">: .exists ( str len -- )
2dup file-status nip 0= if
s" input.txt" .exists
s" /input.txt" .exists
." exists: "
else
s" docs" .exists
." does not exist: "
s" /docs" .exists</syntaxhighlight>
then
type
;

s" input.txt" .exists cr
s" /input.txt" .exists cr
s" docs" .exists cr
s" /docs" .exists cr
</syntaxhighlight>

=={{header|Fortran}}==
=={{header|Fortran}}==
{{works with|Fortran|90 and later}}
{{works with|Fortran|90 and later}}