home *** CD-ROM | disk | FTP | other *** search
- /************************************************************************/
- /* When PowerPlatform invokes an ARexx EXEC, it optionally passes the */
- /* full file name, including path to the EXEC. This sample EXEC shows */
- /* you how to break apart the filename. You can use it to develop your */
- /* own EXEC's. */
- /* */
- /* For example: If the following was passed: */
- /* */
- /* DH0:Dir1/Dir2/FileName.Type */
- /* */
- /* This EXEC will set the ARexx variables fpath, fname and ftype as */
- /* follows: */
- /* */
- /* fpath = DH0:Dir1/Dir2 (File path) */
- /* fname = FileName.Type (File name) */
- /* ftype = Type (File type) */
- /* */
- /* Additionally this EXEC will validate the file type, if it is not */
- /* "C", it will display an error. */
- /* */
- /* Again, this is just an example. You can adapt it to meet your needs. */
- /* */
- /* ==> MCW 09/03/90 <== */
- /* */
- /* Copyright © 1990 Martin C. Warnett. */
- /************************************************************************/
-
- trace ?i
-
-
- parse arg full_name /* Get full path/filename */
-
- ftypep = lastpos(".", full_name) /* Find file type position */
- fnamep = lastpos("/", full_name) /* Find file name position */
-
- if fnamep = 0 then do /* No path? */
- fnamep = lastpos(":", full_name) /* Find end of device name */
- fpath = substr(full_name, 1, fnamep) /* Get device name */
- end
- else do
- fpath = substr(full_name, 1, fnamep-1) /* Get file path */
- end
-
- fname = substr(full_name, fnamep+1) /* Get filename and type */
-
- if ftypep = 0 then do /* No file type? */
- ftype = "" /* Set type to NULL string */
- end
- else do /* Strip off file type */
- ftype = substr(full_name, ftypep + 1) /* Get filetype */
- end
-
- ftype = upper(ftype) /* Upper case for editing */
-
- if ftype ~= "C" then do /* Invalid filetype? */
- 'message Invalid file type' /* Msg in PP title bar */
- 'beep' /* Sound the alarm */
- return 8 /* Return with error */
- end
-
- 'message FNAME=' || fname || ', FTYPE=' || ftype
- return 0
-