home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 6 File / 06-File.zip / fm2utils.zip / subj.cmd < prev    next >
OS/2 REXX Batch file  |  1998-05-25  |  3KB  |  81 lines

  1. /*
  2.  * assign a WPS .SUBJECT EA to a file.
  3.  * SUBJ for help.
  4.  */
  5.  
  6. oldsubj = ''
  7. parse arg filename text
  8. text = left(text,40)
  9. text = strip(text)
  10. filename = strip(filename)
  11. if left(filename,1) = d2c(34) then
  12. do
  13.   text = ''
  14.   parse arg filename
  15.   filename = substr(filename,2)
  16.   if right(filename,1) = d2c(34) then
  17.     filename = left(filename,length(filename) - 1)
  18. end
  19. if filename = '/?' then filename = ''
  20. if filename \= '' then
  21. do
  22.   call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  23.   call SysLoadFuncs
  24.   if text = '' then
  25.   do
  26.     /* note how this obtains and displays an existing .SUBJECT EA
  27.        you can use this as a pattern for your own rexx programs that
  28.        manipulate .SUBJECT EAs */
  29.     if SysGetEA(filename,'.SUBJECT','oldsubj') = 0 then
  30.     text = oldsubj
  31.     do
  32.       if text \= '' then
  33.         say 'Current .SUBJECT: 'substr(text,5)
  34.     end
  35.     /* get input from user for new subject text */
  36.     say 'Enter new .SUBJECT (or press CTRL-C then [Enter] to abort): '
  37.     pull text
  38.     text = left(text,40)
  39.     text = strip(text)
  40.   end
  41.   if text \= '' then
  42.   do
  43.     /* build the .SUBJECT EA data in variable description.
  44.        note that variable text contains the string,
  45.        and description is prepared with essential information,
  46.        then has the string added to it.  you can use this as a
  47.        pattern for writing your own rexx programs that manipulate
  48.        .SUBJECT EAs. */
  49.     description = 'FDFF'x || d2c(length(text)) || '00'x || text
  50.     /* now place the constructed EA data into the file's .SUBJECT EA */
  51.     call SysPutEA filename,'.SUBJECT',description
  52.     /* grab EA again and display for feedback to user */
  53.     call SysGetEA filename,'.SUBJECT','text'
  54.     say filename"'s subject is now: "substr(text,5)
  55.   end
  56.   else
  57.   do
  58.     /* erase the old .SUBJECT EA */
  59.     call SysPutEA filename,'.SUBJECT',''
  60.     if oldsubj \= '' then
  61.       say 'Erased 'filename"'s subject."
  62.   end
  63. end
  64. else
  65. do
  66.   say 'SUBJ is a utility to set .SUBJECT EAs from the command line.'
  67.   say ''
  68.   say 'Usage: SUBJ filename text for subject'
  69.   say '    or SUBJ filename (display old subject, allows entry of new)'
  70.   say ''
  71.   say ' filename is required.  If filename contains blanks, surround filename'
  72.   say ' with quote marks and do _not_ give a subject on the command line (must'
  73.   say ' be entered interactively).'
  74.   say ''
  75.   say 'Examples: SUBJ filename'
  76.   say '          SUBJ filename A most useful comment'
  77.   say '          SUBJ 'd2c(34)'a long filename'd2c(34)
  78.   say ''
  79.   say 'Hector wuz here.'
  80. end
  81.