home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / cvtaddr.zip / CVTADDR.CMD < prev    next >
OS/2 REXX Batch file  |  1995-09-03  |  4KB  |  120 lines

  1. /********************************************************************/
  2. /* REXX Script to Convert LaMail(TM) Address Files to PMMail Format */
  3. /* This utility written by David J. Looney, 2 September 1995        */
  4. /* Released into the public domain. NO WARRANTY of any kind applies */
  5. /* to this utility.  Suitability, performance, and safety of your   */
  6. /* data is not guaranteed. Use at your own risk.                    */
  7. /********************************************************************/
  8.  
  9. /* Output Utility Message */
  10. SAY "CVTADDR: UTILITY TO CONVERT LaMail/Ultimail ADDRESS FILES"
  11. SAY "         TO PMMail ADDRESS FILE FORMAT.  D. Looney, 1995.  "
  12. SAY ""
  13. SAY "Create separate address files in PMMail for each file to"
  14. SAY "import, or combine LaMail/UltiMail Lite files with a text"
  15. SAY "editor prior to import under the name of a previously"
  16. SAY "created PMMail address file.  LaMail addresses are found"
  17. SAY "in the \tcpip\LaMail\nickname.nam file. UltiMail may create"
  18. SAY "multiple address books.  They can be found by changing to"
  19. SAY "the root directory and typing 'dir *.hnm /s'.  Under HPFS"
  20. SAY "you may have to use quotes to enclose the long filenames "
  21. SAY "(e.g. 'Address Book.HNM').  Run CVTADDR and designate the"
  22. SAY "output file(s) under the name(s) of previously created "
  23. SAY "PMMail address books, and either copy these files to the"
  24. SAY "PMMail 'Address' directory, or use a text editor to add "
  25. SAY "the converted addresses to an existing PMMail address book."
  26. SAY "DO NOT OVERWRITE A PMMAIL FILE CONTAINING ADDRESSES."
  27. SAY ""
  28.  
  29. /* Get File Parameters */
  30. CALL CHAROUT ,"Enter Name of Input File: "
  31. PARSE PULL InFile
  32. CALL CHAROUT ,"Enter Name of Output File: "
  33. PARSE PULL OutFile
  34.  
  35. /* Open Files */
  36. rc=STREAM(InFile, 'c', 'open read')
  37. IF rc<> 'READY:' THEN SIGNAL INFILE_ERROR
  38. rc=STREAM(OutFile, 'c', 'open write')
  39. IF rc<> 'READY:' THEN SIGNAL OUTFILE_ERROR
  40.  
  41. /* Initialize Variables */
  42. Addresses.0=0
  43. Tally=0
  44. currentln=""
  45.  
  46. /* Start on beginning of record */
  47. DO WHILE (POS(':nick.',currentln)<>1) & (LINES(InFile)<>0)
  48.    currentln=LINEIN(InFile)
  49. END
  50.  
  51. /* Parse File */
  52. DO WHILE lines(InFile)<>0 
  53.    RecordStart=POS(':nick.',currentln)
  54.    Tally=Tally+1
  55.    Addresses.0=Tally
  56.    Nick=SUBSTR(currentln,7,LENGTH(currentln)-6)
  57.    currentln=LINEIN(InFile)
  58.    Name=''
  59.    Node=''
  60.    Userid=''
  61.    Phone=''
  62.    DO WHILE (POS(':nick',currentln)<>1) & (LINES(Infile)<>0)
  63.        Strlen=LENGTH(currentln)
  64.        IsName=POS(':name.',currentln)
  65.        IF IsName<>0 THEN
  66.          DO
  67.            Name=RIGHT(currentln,Strlen-(IsName+5))
  68.          END
  69.        IsNode=POS(':node.',currentln)
  70.        IF IsNode<>0 THEN
  71.          DO
  72.            Node=RIGHT(currentln,Strlen-(IsNode+5))
  73.          END
  74.        IsUserID=POS(':userid.',currentln)
  75.        IF IsUserID<>0 THEN
  76.          DO
  77.            Userid=RIGHT(currentln,Strlen-(IsUserID+7))
  78.          END
  79.        IsPhone=POS(':phone.',currentln)
  80.        IF IsPhone<>0 THEN
  81.          DO
  82.            Phone=RIGHT(currentln,Strlen-(IsPhone+6))
  83.          END
  84.        currentln=LINEIN(InFile)
  85.    END
  86.    /* Build PMMail Address File Lines */
  87.    Addresses.Tally.TITLE=Name||' ('||Nick||')'
  88.    Addresses.Tally.EMAIL=Userid||'@'||Node
  89.    Addresses.Tally.COMPANY=' '
  90.    Addresses.Tally.FONE=Phone
  91.    Addresses.Tally.COMMENT=' '
  92.    /* Write PMMail Address File Entry */
  93.    CALL LINEOUT OutFile, Addresses.Tally.TITLE
  94.    CALL LINEOUT OutFile, Addresses.Tally.EMAIL
  95.    CALL LINEOUT OutFile, Addresses.Tally.COMPANY
  96.    CALL LINEOUT OutFile, Addresses.Tally.FONE
  97.    CALL LINEOUT OutFile, Addresses.Tally.COMMENT
  98. END
  99.  
  100. /* Close Files */
  101. CALL STREAM InFile, 'c', 'close'
  102. CALL STREAM OutFile, 'c', 'close'
  103.  
  104. EXIT
  105.  
  106. /* Error Routines */
  107. INFILE_ERROR:
  108. Say ''
  109. Say 'Error Opening File: '||InFile
  110. Say ''
  111. EXIT
  112.  
  113. OUTFILE_ERROR:
  114. Say ''
  115. Say 'Error Creating/Opening File: '||OutFile
  116. Say ''
  117. EXIT
  118.  
  119.  
  120.