home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / dmrxwps1.zip / DelTmplt.cmd next >
OS/2 REXX Batch file  |  1996-08-03  |  2KB  |  62 lines

  1. /* DelTmplt.cmd - A REXX script that utilizes DMrxWPS and RexxUtil   */
  2. /*                to delete templates from the Templates folder.     */
  3.  
  4. /* Add RexxUtil functions */
  5. rc = rxFuncAdd( 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs');
  6. rc = SysLoadFuncs();
  7.  
  8. /* Add DMrxWPS functions */
  9. rc = rxFuncAdd( 'WpsLoadFuncs', 'DMrxWPS', 'WpsLoadFuncs');
  10. rc = WpsLoadFuncs(); say rc;
  11.  
  12. /* Parse template name */
  13. parse arg '"' TemplateName '"';
  14. if TemplateName == '' then parse arg TemplateName;
  15.  
  16. /* If no arg name given */
  17. if TemplateName == '' then
  18.   do
  19.     /* Display usage */
  20.     say 'Usage: DelTmplt <template name>';
  21.     exit;
  22.   end;
  23.  
  24. /* Get path to template folder */
  25. hTemplateFolder = WpsQueryObject( '<WP_TEMPS>');
  26. rc = WpsQueryObjectPath( hTemplateFolder, TemplatePath);
  27. if rc == 0 then
  28.   do
  29.     say 'Error getting path to Tempaltes folder.';
  30.     exit;
  31.   end;
  32.  
  33. /* Build fully qualified template pathname */
  34. Template = TemplatePath || '\' || TemplateName;
  35.  
  36. /* Get handle of template */
  37. hTemplate = WpsQueryObject( Template);
  38.  
  39. /* If hTemplate is 0x00000000, maybe it's an abstract template */
  40. if hTemplate == '0x00000000' then
  41.   do
  42.     say 'Unable to delete template ''' || TemplateName || '''.';
  43.     say 'The template may not exist or may be abstract.'
  44.     exit;
  45.   end;
  46.  
  47. /* Delete template */
  48. rc = SysDestroyObject( Template);
  49.  
  50. /* Check result */
  51. if rc == 0 then
  52.   do
  53.     say 'Error deleting template ''' || TemplateName || '''.';
  54.     exit;
  55.   end;
  56. else
  57.   do
  58.     say 'Template' TemplateName 'deleted.';
  59.   end;
  60.  
  61. exit;
  62.