home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / internet / yamtools20 / yamtools20english / changebound.rexx < prev    next >
OS/2 REXX Batch file  |  1997-08-08  |  9KB  |  186 lines

  1. /******************************************************************************/
  2. /*                                                                            */
  3. /*                              ChangeBound                                   */
  4. /*                 Copyright ©1997 by Dick Whiting                            */
  5. /*                                                                            */
  6. /*----------------------------------------------------------------------------*/
  7. /*  This program will make MIMED mail readable in Yam that has the boundary   */
  8. /*  set to ALL dashes. Boundary lines and the End Boundary are changed to     */
  9. /*  a new value that Yam will be happy with.                                  */
  10. /*                                                                            */
  11. /*  NOTE: This one, like my other ones, retains the date/timestamp of the     */
  12. /*        original mail and its filenote.                                     */
  13. /*                                                                            */
  14. /*  NOTE: IF someone manages to have a line of DASHES of EXACTLY the correct  */
  15. /*        length of the original boundary, this script and therefore Yam      */
  16. /*        will STILL be confused.                                             */
  17. /*                                                                            */
  18. /*  SUGGESTION: Write to the Digest/List administrator and suggest using a    */
  19. /*        Boundary value that will NOT be accidentally found in someone's     */
  20. /*        mail. A good choice would be something with a datetime stamp and    */
  21. /*        maybe the digest number.                                            */
  22. /*                                                                            */
  23. /*----------------------------------------------------------------------------*/
  24. /*  If you use YamTools you can use this one as a TYPE=ONCE to apply to mail  */
  25. /*  selected one at a time from YAM, or TYPE=MAIL to do all mail selected     */
  26. /*  from a YamTools list.  Remember that you CAN define two buttons using     */
  27. /*  same script but with different TYPES.                                     */
  28. /*                                                                            */
  29. /*  If you don't use YamTools--why not;)                                      */
  30. /*                                                                            */
  31. /*----------------------------------------------------------------------------*/
  32. /*                                                                            */
  33. /* Standard Disclaimer: I wrote it, it works for me, I don't guarantee        */
  34. /* that it will do anything productive for anyone else, etc. etc. ;-)         */
  35. /*                                                                            */
  36. /*HOWEVER, if you DO find a use for it: I homeschool my kids and they         */
  37. /*would love a postcard from where EVER you live.                             */
  38. /*                                                                            */
  39. /*Instant GEOGRAPHY lesson;)                                                  */
  40. /*                                                                            */
  41. /*                                                                            */
  42. /*POSTCARDS:    Dick Whiting                                                  */
  43. /*              28590 S. Beavercreek Rd.                                      */
  44. /*              Mulino, Oregon 97042                                          */
  45. /*              USA                                                           */
  46. /*                                                                            */
  47. /*----------------------------------------------------------------------------*/
  48. /*                                                                            */
  49. /*               Address Bug Reports or Comments to:                          */
  50. /*                Dick Whiting <dwhiting@europa.com>                          */
  51. /*                            19 July 1997                                    */
  52. /*                                                                            */
  53. /******************************************************************************/
  54. /*
  55. $VER: 1.0 Copyright ©1997 by Dick Whiting
  56. $AUTHOR: Dick Whiting
  57. $DESCRIPTION: Change Boundary of all dashes to new value        
  58. */
  59.  
  60. options results
  61.  
  62. argpassed=''
  63. parse arg argpassed 
  64.  
  65. Call Localize
  66.  
  67. /******************************************************************************/
  68. /*  Find out the necessary information about the file                         */
  69. /******************************************************************************/
  70. Init:
  71.  
  72. if ~show('L','rexxsupport.library') then do
  73.    addlib('rexxsupport.library',0,-30)
  74. end
  75.  
  76. Address YAM 'getmailinfo file'
  77. mfile=result
  78. slpos=lastpos('/',mfile)
  79. copos=lastpos(':',mfile)
  80. filename=strip(substr(mfile,max(slpos,copos)+1))
  81. tmpfile = 'T:'||filename                              /* temporary file       */
  82. fstate=statef(mfile)                                  /* file information     */
  83. fbytes=subword(fstate,2,1)                            /* length of file       */
  84. fdate=subword(fstate,5,1)                             /* internal date        */
  85. fmins=subword(fstate,6,1)                             /* minutes since midnite*/
  86. fticks=subword(fstate,7,1)                            /* ticks past minutes   */
  87. fcomm=subword(fstate,8)                               /* old comment          */
  88.  
  89. fdate=date('E',fdate,'I')                             /* get date in ddmmyy   */
  90. fdate=translate(fdate,'-','/')                        /* convert / to -       */
  91. hh=fmins%60                                           /* get hours            */
  92. hh=right(hh,2,'0')                                    /* force to 2 digits    */
  93. mm=fmins//60                                          /* get minutes          */
  94. mm=right(mm,2,'0')                                    /* force to 2 digits    */
  95. ss=fticks%50                                          /* seconds              */
  96. ss=right(ss,2,'0')                                    /* force it             */
  97. ftime=hh||':'||mm||':'||ss                            /* timestamp rebuilt    */
  98.  
  99. TRUE=1
  100. FALSE=0
  101. FixBound=FALSE
  102. header=TRUE
  103. outopen=FALSE
  104.  
  105. newbound='Modified.by.ChangeBound.rexx.'date()'.'time()
  106. newbound=translate(newbound,'..',' :')
  107.  
  108. /******************************************************************************/
  109. /*  Do the actual modifications to the mail file.                             */
  110. /******************************************************************************/
  111. ChangeBounds:
  112.  
  113. if open('OUT',tmpfile,'W') then do
  114.    outopen=TRUE
  115.    if open('IN',mfile,'R') then do
  116.       do until eof('IN')
  117.          linein = readln('IN')
  118.          select
  119.             when header & linein='' then header=FALSE
  120.             when header & upper(word(linein,1))='CONTENT-TYPE:' then do
  121.                boundpos=pos('BOUNDARY=',upper(linein))
  122.                if boundpos>0 then do
  123.                   bound1=substr(linein,1,boundpos+8)
  124.                   boundary=substr(linein,boundpos+9)
  125.                   boundary=strip(boundary,'B','"')
  126.                   if boundary~='' & verify('-',boundary)=0 then do 
  127.                      oldbound='--'||boundary
  128.                      oldend=oldbound||'--'
  129.                      boundary=newbound
  130.                      linein=bound1||'"'||newbound||'"'
  131.                      newbound='--'||newbound
  132.                      newend=newbound||'--'
  133.                      FixBound=TRUE
  134.                   end
  135.                   else do
  136.                      leave
  137.                   end
  138.                end
  139.             end
  140.             when strip(linein,'B')=oldbound then linein=newbound
  141.             when strip(linein,'B')=oldend then linein=newend
  142.             otherwise nop
  143.          end
  144.          foo=writeln('OUT',linein)
  145.       end
  146.       foo=close('IN')
  147.       foo=close('OUT')
  148.       outopen=FALSE
  149.       if FixBound then do
  150.          Address Command 'C:Copy 'tmpfile' 'mfile 
  151.          Address Command 'SetDate  ' mfile fdate ftime 
  152.          Address Command 'Filenote ' mfile '"'fcomm'"' 
  153.       end
  154.    end
  155.    if outopen then do
  156.       foo=close('OUT')
  157.    end
  158.    Address Command 'Delete 'tmpfile 'QUIET'
  159. end
  160.  
  161. if argpassed='' then do
  162.    if FixBound then do
  163.       Address YAM 'request "'donemsg'" "'yesnomsg'"'
  164.       ans=result
  165.       if ans=1 then do
  166.          Address YAM 'mailupdate'
  167.       end
  168.    end
  169.    else do
  170.       Address YAM 'request "'goodBmsg'" "'okmsg'"'
  171.    end
  172. end
  173.  
  174. exit
  175.  
  176. /******************************************************************************/
  177. /*  Variables available for localization.                                     */
  178. /******************************************************************************/
  179. Localize:
  180.  
  181. donemsg='Done..Update Index?'
  182. yesnomsg='Yes|No'
  183. goodBmsg='Good boundary..exiting'
  184. okmsg='OK'
  185.  
  186.