home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / postroad.zip / note2asc.cmd < prev    next >
OS/2 REXX Batch file  |  1997-10-23  |  4KB  |  108 lines

  1. /*                 To create an .ASC file from any or all                 */
  2. /*                       addresses found in a note                        */
  3. /*                         Parameters: note_file                          */
  4. /*    InnoVal Systems Solutions, Inc., and the authors cannot be held     */
  5. /*   responsible for damage that might occur while using this program.    */
  6. /*                         Use at your own risk.                          */
  7.  
  8. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  9. signal on syntax name NoRexx
  10. call SysLoadFuncs
  11. signal on syntax name Syntax
  12. '@ECHO OFF'
  13. parse arg filename
  14. if filename='' then do
  15.    say ""
  16.    say "Creates .ASC file (from which ASC2ADR.CMD can create a Post Road Mailer"
  17.    say "address book file) from any or all addresses found in a note file."
  18.    say "Specify the filename of the note as a command line parameter."
  19.    say ""
  20.    exit
  21. end
  22. if translate(right(filename,4))<>'.POP' then filename=filename||'.POP'
  23. if stream(filename,'c','query exists')='' then do
  24.    say "File" filename "does not exist."
  25.    exit
  26. end
  27. addresses=0 ; data.=''
  28. do while lines(filename)
  29.    line=linein(filename)
  30.    check=line
  31.    do while pos('@',check)>0
  32.       parse var check now check
  33.       star=pos('@',now)
  34.       if star>0 & pos('.',now)>star then do
  35.          addresses=addresses+1
  36.          if left(now,1)='05'x then parse var now . 3 now
  37.          if left(now,1)='<' then parse var now . '<' now '>'
  38.          if left(now,1)='(' then parse var now . '(' now ')'
  39.          if left(now,1)='[' then parse var now . '[' now ']'
  40.          if left(now,1)='{' then parse var now . '{' now '}'
  41.          if left(now,1)='"' then parse var now . '"' now '"'
  42.          if left(now,1)="'" then parse var now . "'" now "'"
  43.          data.string.addresses=now
  44.          data.lin.addresses=line
  45.       end
  46.    end
  47. end
  48. do i=1 to addresses
  49.    say ""
  50.    say "Address" data.string.i "found in line"
  51.    say data.lin.i
  52.    say ""
  53.    say "Please enter name, if desired:"
  54.    parse pull data.name.i
  55.    if data.name.i<>'' then do
  56.       if outfile='OUTFILE' then do
  57.          outfile=systempfilename('PRMBK???.ASC')
  58.          Call LineOut outfile, 'Addresses from' filename 'note (Post Road Mailer address book)'
  59.          Call LineOut outfile, 'The fields are:'
  60.          Call LineOut outfile, 'Last Name<tab>First Name<tab>Organization<tab>Email 1<tab>Nickname 1<tab>....Email 5<tab>Nickname 5<tab>Telephone 1<tab>Telephone 2<tab>Fax<tab>Notes 1<tab>Notes 2<tab>Notes 3<tab>....Notes X'
  61.          call lineout outfile,''
  62.       end
  63.       call entry data.string.i data.name.i
  64.    end
  65. end
  66. if email<>'EMAIL' then do
  67.    say ""
  68.    say "The address book entrie(s) have been saved in file" outfile
  69.    say "(Press any key to exit....)"
  70.    call sysgetkey
  71. end
  72. exit
  73. entry:
  74.    parse arg email nametext
  75.    last='' ; first='' ; check=''
  76.    nametext=strip(nametext)
  77.    if pos(',',nametext)>0 then do
  78.       parse var nametext last ',' first
  79.       first=strip(first)
  80.       check=translate(first)
  81.       if check='JR.' | check='SR.' | check='JR' | check='SR' | check='' then do
  82.          lastspace=lastpos(' ',last)
  83.          check=first
  84.          parse var last first =(lastspace) last
  85.          last=last check
  86.       end
  87.    end
  88.    else do
  89.       lastspace=lastpos(' ',nametext)
  90.       parse var nametext first =(lastspace) last
  91.    end
  92.    last=strip(last)
  93.    first=strip(first)
  94.    if last='' then last=first
  95.    if last=first then first=''
  96.    call lineout outfile,LAST||'09'x||FIRST||'09'x||'09'x||EMAIL||copies('09'x,13)
  97. return
  98. Syntax:
  99.   say 'Error' rc 'in line' sigl':' errortext(rc)
  100.   say sigl':' sourceline(sigl)
  101.   exit
  102. return
  103. NoRexx:
  104.    say 'Unable to load the REXXUtil functions.  Either the REXXUTIL.DLL file'
  105.    say 'is not on the LIBPATH or REXX support is not installed on this system.'
  106.    exit
  107. return
  108.