home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / dongrovs.zip / replyto.cmd < prev    next >
OS/2 REXX Batch file  |  1996-10-16  |  2KB  |  76 lines

  1. /* Reply.cmd */
  2. /* OS/2 Rexx Script for MR/2 ICE */
  3. /* by William H. Geiger III 04 May 96 */
  4. /* Geiger Consulting   */
  5. /* whgiii@amaranth.com */
  6. /* this script will add a Reply To stamp in the message header */
  7. /* for message from a list server */
  8.  
  9. Argv = .ARRAY_CLI~of(ARG(1), .false, .false) /* parse the arguments */
  10. IF Argv~items > 0
  11. THEN DO
  12.        /* assume first parameter is the name of a *.RCV format file */
  13.    msg_file = .RcvTextStream~new(Argv[1])
  14.  
  15.       /* read the contents into a List */
  16.    msg_file~OPEN('READ')
  17.    msg_List = msg_file~MakeList
  18.    msg_file~CLOSE
  19.  
  20.       /* These are the two fieldnames where looking for */
  21.    ySender = 'Sender:'
  22.    yReply  = 'Reply-to:'
  23.  
  24.    snd=''                  /* sender field data */
  25.    rpl= .nil               /* reply to Location */
  26.    lastHeader = .nil       /* location of last Header line */
  27.    su = msg_list~supplier
  28.    do while su~available
  29.       SELECT
  30.         WHEN su~item~Strip~length = 0
  31.         THEN LEAVE      /* when end of header section is reached */
  32.         WHEN su~item~pos(ySender,1) = 1
  33.         THEN DO
  34.            parse value su~item with . ':' snd
  35.            snd = snd~strip('L')
  36.            if snd~pos('owner-') \= 1
  37.            THEN LEAVE
  38.         END
  39.         WHEN su~item~pos(yReply,1) = 1 & rpl = .nil
  40.         THEN rpl= su~index
  41.         OTHERWISE NOP
  42.       END
  43.       lastHeader = su~index
  44.       su~next
  45.    end
  46.      /* If Sender's name start with 'owner-' we've found one to update */
  47.    if snd~pos('owner-') = 1
  48.    THEN DO
  49.       nReply = yReply~' '(snd~substr(7))
  50.       upDate = .TRUE
  51.       SELECT
  52.         WHEN rpl = .nil
  53.         THEN rpl = LastHeader
  54.         WHEN msg_list[rpl] == nReply
  55.         THEN upDate = .False
  56.         OTHERWISE rpl = msg_List~Previous(rpl)
  57.       END
  58.       IF upDate   /* If not already updated */
  59.       THEN DO
  60.          /* add new/additional Reply-to: field in first postion */
  61.          msg_List~insert(nReply,rpl)
  62.  
  63.             /* Write the updated contents back to the disk */
  64.          msg_file~OPEN('WRITE REPLACE')
  65.          msg_File~WriteList(msg_list)
  66.          msg_file~CLOSE
  67.       END
  68.    END
  69.      /* Are not OREXX List's easy to deal with */
  70. END
  71. return 0
  72.  
  73. ::requires Array_Cli
  74. ::requires TextStream
  75.  
  76.