Check that file exists: Difference between revisions

Content added Content deleted
m (→‎version 1: elided the checking if a named directory exists.)
Line 1,941: Line 1,941:
{{works with|Personal REXX}}
{{works with|Personal REXX}}
{{works with|Regina}}
{{works with|Regina}}
<lang rexx>/*REXX pgm creates a new empty file and directory; in curr dir and root.*/
<lang rexx>/*REXX program creates a new empty file and directory in current directory and root dir.*/
fn= 'input.txt' /*default name of a file. */
fn='input.txt'
dn= 'docs' /*default name of a directory (folder).*/
dn='docs'
@.1='current directory'; @.2='root directory' /*msgs for each pass.*/
@.1= 'current directory'; @.2= 'root directory' /*messages used to indicate which pass.*/
parse upper version v; regina=pos('REGINA',v)\==0 /*Regina being used? */
parse upper version v /*obtain name of the REXX being used. */
regina= pos('REGINA', v)\==0 /*is this the Regina REXX being used? */


do j=1 for 2; say /*perform these statements twice.*/
do j=1 for 2; say /* [↑] perform these statements twice.*/
if stream(fn,'C',"QUERY EXISTS")=='' then say 'file ' fn " doesn't exist in the" @.j
if stream(fn, 'C', "QUERY EXISTS")=='' then say 'file ' fn " doesn't exist in the" @.j
else say 'file ' fn " does exist in the" @.j
else say 'file ' fn " does exist in the" @.j
if dosisdir(dn) then say 'directory ' dn " does exist in the" @.j
if j==1 then if regina then call chdir '\' /*use Regina's version of CHDIR. */
else say 'directory ' dn " doesn't exist in the" @.j
else call doschdir '\' /*PC/REXX & Personal REXX version. */
if regina then call chdir '\' /*use Regina's version of CHDIR.*/
end /*j*/ /*now, go and perform them again. */
else call doschdir '\' /*PC/REXX & Personal REXX version*/
/*stick a fork in it, we're all done. */</lang>
end /*j*/ /*now, go and perform them again.*/
/*stick a fork in it, we're done.*/</lang>


===version 2===
===version 2===