/*********************************************************************** * Safe file creation with append option * Usage: If safecrea2(fid)<>1 Then Exit ... * After this, happily start creating file fid, starting from scratch ************************************************************************ * Prereq: exists, pryn * Change Activity: * 15.05.2015 PA polished for RexxLA * 05.06.2015 Les improved the options ***********************************************************************/ Parse Arg fid If fid='?' | fid='' Then Do Say 'Checks if the specified file exists' Say ' and prompts the user if it does.' Exit 0 End retval=1 If exists(fid) Then Do Do ri=1 By 1 Until words(response)=1 & pos(response,'R A X')>0 If ri>1 Then Say 'Try again. Choose one of: R A X' Say 'File' fid 'already exists: Replace, Append or eXit?' Parse Pull response response=translate(response) End Select When response='R' Then Do Call sysFileDelete fid Say fid 'will be replaced.' End When response='A' Then Say fid 'will be appended to.' Otherwise retval=0 End End Else Nop /* Say fid 'will be created.' */ /* Say 'safecrea2 retval='retval */ Return retval