home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 492.lha / PowerPlatform_v1.1 / Rexx / Strip.APP < prev   
Encoding:
Text File  |  1991-04-06  |  3.3 KB  |  63 lines

  1. /************************************************************************/
  2. /* When PowerPlatform invokes an ARexx EXEC, it optionally passes the   */
  3. /* full file name, including path to the EXEC. This sample EXEC shows   */
  4. /* you how to break apart the filename. You can use it to develop your  */
  5. /* own EXEC's.                                                          */
  6. /*                                                                      */
  7. /* For example: If the following was passed:                            */
  8. /*                                                                      */
  9. /*     DH0:Dir1/Dir2/FileName.Type                                      */
  10. /*                                                                      */
  11. /* This EXEC will set the ARexx variables fpath, fname and ftype as     */
  12. /* follows:                                                             */
  13. /*                                                                      */
  14. /*     fpath = DH0:Dir1/Dir2                    (File path)             */
  15. /*     fname = FileName.Type                    (File name)             */
  16. /*     ftype = Type                             (File type)             */
  17. /*                                                                      */
  18. /* Additionally this EXEC will validate the file type, if it is not     */
  19. /* "C", it will display an error.                                       */
  20. /*                                                                      */
  21. /* Again, this is just an example. You can adapt it to meet your needs. */
  22. /*                                                                      */
  23. /*                                              ==> MCW 09/03/90 <==    */
  24. /*                                                                      */
  25. /*                   Copyright © 1990 Martin C. Warnett.                */
  26. /************************************************************************/
  27.  
  28. trace ?i
  29.  
  30.  
  31. parse arg full_name                         /* Get full path/filename   */
  32.  
  33. ftypep = lastpos(".", full_name)            /* Find file type position  */
  34. fnamep = lastpos("/", full_name)            /* Find file name position  */
  35.  
  36. if fnamep = 0 then do                       /* No path?                 */
  37.     fnamep = lastpos(":", full_name)        /* Find end of device name  */
  38.     fpath = substr(full_name, 1, fnamep)    /* Get device name          */
  39. end
  40. else do
  41.     fpath = substr(full_name, 1, fnamep-1)  /* Get file path            */
  42. end
  43.  
  44. fname = substr(full_name, fnamep+1)         /* Get filename and type    */
  45.  
  46. if ftypep = 0 then do                       /* No file type?            */
  47.     ftype = ""                              /* Set type to NULL string  */
  48. end
  49. else do                                     /* Strip off file type      */
  50.     ftype = substr(full_name, ftypep + 1)   /* Get filetype             */
  51. end
  52.  
  53. ftype = upper(ftype)                        /* Upper case for editing   */
  54.  
  55. if ftype ~= "C" then do                     /* Invalid filetype?        */
  56.     'message Invalid file type'             /* Msg in PP title bar      */
  57.     'beep'                                  /* Sound the alarm          */
  58.     return 8                                /* Return with error        */
  59. end
  60.  
  61. 'message FNAME=' || fname || ', FTYPE=' || ftype
  62. return 0
  63.