home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / ozwgcp.cmd < prev    next >
OS/2 REXX Batch file  |  1996-07-16  |  4KB  |  131 lines

  1. /* OZWGCP.CMD by William J. Hinkle [75300,2050] */
  2. /* This Rexx script translates OZCIS/Win address books to GCP USERID.CIS */
  3. /* Just run it from an OS/2 command line or a desktop program object     */
  4. /*
  5.  
  6.   Title   : Translates OZCIS-Win Address Books to GCP form                       
  7.   Keywords: GCP GOLDEN COMMPASS OZCIS WIN OZARK ADDRESS ADDRESSBOOK TRANSLATE   
  8.                                                                            
  9.   This OS/2 Rexx program reads your OZCIS-Windows address book and
  10.   appends the addresses to your Golden CommPass address book.
  11.   If you have problems, I'll be interested to see your OZCIS
  12.   ADDRBOOK.AB file. Freeware, uploaded by author.
  13.  
  14. */
  15. uppert = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  16. lowert = "abcdefghijklmnopqrstuvwxyz"
  17. SIGNAL ON HALT
  18.  
  19. gcpok = ""
  20. DO UNTIL gcpok = "READY:"
  21.     IF gcpok <> "" THEN SAY gcpaddr "could not be found!"
  22.     SAY "Please enter the drive:directory to the Golden CommPass addressbook USERID.CIS."
  23.     SAY "Just [Enter] for C:\GCP\ or [Ctrl+C][Enter] to quit: ";
  24.     PARSE PULL gcppath
  25.     gcppath = STRIP(gcppath,"B")
  26.     IF gcppath = "" THEN
  27.         gcppath = "C:\GCP\"
  28.     ELSE DO
  29.         IF RIGHT(gcppath,1) <> "\" AND RIGHT(gcppath,1) <> ":" THEN DO
  30.             gcppath = gcppath || "\"
  31.         END
  32.     END
  33.     gcpaddr = gcppath || "USERID.CIS"
  34.     IF STREAM(gcpaddr,"C","QUERY EXISTS") <> "" THEN DO
  35.         SAY "Did you already save" gcpaddr "just in case...? [Y/N][Enter]:"
  36.         PARSE UPPER PULL strdat
  37.         IF strdat <> "Y" THEN DO
  38.             SAY "You'd better do that right now, and try this again later!"
  39.             EXIT
  40.         END
  41.     END
  42.     gcpok = STREAM(gcpaddr,"C","OPEN WRITE")
  43. END
  44.  
  45. ozwok = ""
  46. DO UNTIL ozwok = "READY:"
  47.     IF ozwok <> "" THEN SAY ozwaddr "could not be found!"
  48.     SAY "Please enter the drive:directory to the OZCIS-Windows addressbook ADDRBOOK.AB."
  49.     SAY "Just [Enter] for C:\OZWIN\ or [Ctrl+C][Enter] to quit: ";
  50.     PARSE PULL ozwpath
  51.     ozwpath = STRIP(ozwpath,"B")
  52.     IF ozwpath = "" THEN
  53.         ozwpath = "C:\OZWIN\"
  54.     ELSE DO
  55.         IF RIGHT(ozwpath,1) <> "\" AND RIGHT(ozwpath,1) <> ":" THEN DO
  56.             ozwpath = ozwpath || "\"
  57.         END
  58.     END
  59.     ozwaddr = ozwpath || "ADDRBOOK.AB"
  60.     ozwok = STREAM(ozwaddr,"C","OPEN READ")
  61. END
  62.  
  63. IF BITAND(ozwok,gcpok) = "READY:" THEN DO
  64.  
  65.     ncnt = 0
  66.     ozpos = 1
  67.     DO WHILE CHARS(ozwaddr) > 0
  68.  
  69.         /* get the name */
  70.         slen = C2D(CHARIN(ozwaddr,ozpos,1))
  71.         strdat = STRIP(CHARIN(ozwaddr,ozpos+1,slen),"B")
  72.  
  73.         /* un-comment to reverse "last, first" to "first last" if req'd */
  74.         /* 
  75.         endsurname = POS(",", strdat)
  76.         IF endsurname > 0 THEN DO
  77.             strdat = SUBSTR(strdat,endsurname+1) || ,
  78.                      " " || ,
  79.                      SUBSTR(strdat,1,endsurname-1)
  80.         END
  81.         */
  82.         /* build name, fixing case: NAME-> Name */
  83.         nametxt = strdat
  84.         ozpos = ozpos + 1 + slen
  85.  
  86.         /* get the CIS ID or other address */
  87.         slen = C2D(CHARIN(ozwaddr,ozpos,1))
  88.         strdat = STRIP(CHARIN(ozwaddr,ozpos+1,slen),"B")
  89.         IF LEFT(strdat,1) = "[" THEN strdat = SUBSTR(strdat,2)
  90.         IF RIGHT(strdat,1) = "]" THEN strdat = LEFT(strdat,LENGTH(strdat) - 1)
  91.         nametxt = nametxt strdat
  92.         ozpos = ozpos + 1 + slen
  93.  
  94.         /* get notes */
  95.         slen = C2D(REVERSE(CHARIN(ozwaddr,ozpos,2)))
  96.         strdat = STRIP(CHARIN(ozwaddr,ozpos+2,slen),"B")
  97.         ozpos = ozpos + 2 + slen
  98.         IF strdat <> "" THEN DO
  99.             nametxt = nametxt '|'
  100.             /* remove all CR and LF characters */
  101.             slen = 1
  102.             lend = -1
  103.             DO FOREVER
  104.                 lend = POS(D2C(13),strdat,slen)
  105.                 IF lend = 0 THEN DO
  106.                     nametxt = nametxt SUBSTR(strdat,slen)
  107.                     LEAVE
  108.                 END
  109.                 nametxt = nametxt SUBSTR(strdat,slen,lend - slen)
  110.                 slen = lend + 1
  111.                 IF SUBSTR(strdat,slen,1) = D2C(10) THEN slen = slen + 1
  112.             END
  113.         END
  114.  
  115.         ncnt = ncnt + 1
  116.         SAY "#" ncnt "=" nametxt
  117.         IF LINEOUT(gcpaddr,nametxt) <> 0 THEN DO
  118.             SAY "Gagged writing to" gcpaddr "!"
  119.             LEAVE
  120.         END
  121.     END
  122. END
  123. IF ozwok <> "READY:" THEN SAY "Couldn't find the OZCIS-Windows address book file!"
  124. ELSE CALL STREAM ozwaddr,"C","CLOSE"
  125. IF gcpok <> "READY:" THEN SAY "Couldn't find the GCP address book file!"
  126. ELSE CALL STREAM gcpaddr,"C","CLOSE"
  127. EXIT
  128.  
  129. HALT:
  130. EXIT
  131.