home *** CD-ROM | disk | FTP | other *** search
- /*
- ** SafeGetFileName: makes sure that the currently loaded file has an
- ** appropriate name for the operations about to be performed. It is
- ** picky. If the file has no name, it forces the user to save it. If
- ** the file has a name but needs saving, the user is asked if she wants
- ** to continue. And so on...
- **
- ** The full pathname of the file is returned to the calling context.
- */
-
- SafeGetFileName:
- Options RESULTS
-
- GetFileInfo
- parse var RESULT . modified '"'filename'"'
-
- /*
- ** We need a full filepath. Cover all our bases
- */
-
- if modified = NO & filename = "" then do /* is there a file at all? */
- /* no, there isn't */
- RequestBool '"TTX <=> SAS/C" "Load a file to compile?"'
- if RESULT = YES then do /* we get a fullpath this */
- /* way, and load it into TTX */
- drop RESULT
- RequestFile 'PROMPT "Load source file" PATTERN #? sc:'
- fullname = RESULT
- if fullname = "RESULT" then do
- SetStatusBar '"No file to compile"'
- exit 0 /* no file, so leave */
- end
- else
- NOP
- OpenFile fullname
- GetFileInfo
- parse var RESULT . . '"'filename'"'
- end
- else do
- SetStatusBar '"No file to compile"'
- exit 0 /* no file, so leave */
- end
- end
- else do /* yes, there is a file */
- if filename = "" then do /* but it has no name? */
- drop RESULT
- RequestFile 'PROMPT "Save document as..." PATTERN #? sc:'
- fullname = RESULT
- if fullname = "RESULT" then do
- SetStatusBar '"No file to compile"'
- exit 0 /* no file, so leave */
- end
- else
- NOP
- SaveFileAs fullname /* Save the file */
- SetFilePath fullname
- GetFileInfo
- parse var RESULT . . '"'filename'"'
- end
- else do /* File has a name */
- GetFilePath
- fullname = RESULT
- if modified = YES then do /* has it been modified? */
- RequestBool '"TTX <=> SAS/C" "Save before compiling?"'
- if RESULT = YES then
- SaveFile
- else
- NOP
- end
- end
- end
-
- Return fullname
-
-