home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 3 Comm / 03-Comm.zip / PMAC10.ZIP / FIXPRT.CMD next >
OS/2 REXX Batch file  |  1992-05-07  |  5KB  |  163 lines

  1. /*---------------------------------------------------------------
  2.  
  3.   Program:    FIXPRT.CMD
  4.   Op Sys:     OS/2 1.3 or later
  5.   Runtime:    REXX/2
  6.   Libraries:  none
  7.   Author:     Brad Berson
  8.   Date:       April 28, 1992
  9.   History:    1.00  Original version.
  10.  
  11. -----------------------------------------------------------------
  12.  
  13.   FixProtocols  Copyright (C) 1992  Brad Berson  Psycho Psoftware
  14.                   All Rights Reserved.  So There.
  15.  
  16.   You are entitled to freely distribute this file unmodified
  17.   and accompanied by FIXPRT.DOC.  Technical support available via
  18.   CIS:[71631,132], the Ilink OS/2 conference or USPS.
  19.  
  20.   This program corrects defective protocol code numbers in PMcomm
  21.   dialing directory files caused by directory conversions using
  22.   test versions of QMtoPM, the Qmodem->PMcomm .FON translator.
  23.   See the accompanying FIXPRT.DOC for more info.
  24.  
  25.   Invocation:  FIXPRT [PMcomm.FON] [PMcomm.NEW]
  26.   Switches:    none
  27.   FixProtocols dialogue will request info for items not included.
  28.  
  29. -----------------------------------------------------------------
  30.  
  31.       name        c21   1
  32.       number      c21   22    PMCOMM.FON file format:
  33.       baud        c7    43    int 2 byte, long 4 byte (unsigned)
  34.       parity      c5    50    null-terminated/padded strings
  35.       datab       c2    55
  36.       stopb       c2    57    timeson     int   84
  37.       script      c13   59    filesdl     int   86
  38.       protocol    int   72    filesul     int   88
  39.       prefix      int   74    cpsul       int   90
  40.       suffix      int   76    termtype    int   92
  41.       laston      long  78    autosel     int   94
  42.       cpsdl       int   82    fill        c27   96
  43.  
  44. ---------------------------------------------------------------*/
  45.  
  46. cr='0d'x
  47. lf='0a'x
  48. nul='0'x
  49. crlf=cr||lf
  50. recsdone=0
  51. recsfixd=0
  52. pmreclen=122
  53. infile='PMCOMM.FON'
  54. outfile='PMCOMM.NEW'
  55.  
  56. SIGNAL ON HALT NAME ERRH
  57. SIGNAL ON ERROR NAME ERRH
  58. SIGNAL ON SYNTAX NAME ERRH
  59. PARSE UPPER ARG inarg outarg
  60.  
  61. SAY ' '
  62. SAY '* FixProtocols/REXX 1.00, Copyright 1992 Brad Berson'
  63. SAY '* Use ONLY on PMcomm .FON files created by QMtoPM!!!'
  64. SAY ' '
  65.  
  66. IF POS('?',inarg)>0 THEN DO
  67.   SAY 'Invocation:  FIXPRT [PMcomm.FON] [PMcomm.NEW]'
  68.   SAY 'Switches:    none'
  69.   SAY 'FixProtocols dialogue will request info for items not included.'
  70.   EXIT
  71. END
  72.  
  73. IF inarg>'' THEN
  74.   infile=inarg
  75. ELSE DO
  76.   CALL CHAROUT ,'PMcomm FON file specification <'||infile||'>: '
  77.   pmans=LINEIN()
  78.   IF pmans>'' THEN infile=pmans
  79. END
  80.  
  81. IF outarg>'' THEN
  82.   outfile=outarg
  83. ELSE DO
  84.   CALL CHAROUT ,'Output listfile specification <'||outfile||'>: '
  85.   ofans=LINEIN()
  86.   IF ofans>'' THEN outfile=ofans
  87. END
  88.  
  89. IF RIGHT(infile,1)='\' THEN infile=infile||'PMCOMM'
  90. IF RIGHT(outfile,1)='\' THEN outfile=outfile||'PMCOMM'
  91. IF POS('.',infile,LENGTH(infile)-3)=0 THEN infile=infile||'.FON'
  92. IF POS('.',outfile,LENGTH(outfile)-3)=0 THEN outfile=outfile||'.LST'
  93.  
  94. /* Open PMCOMM.FON and get size) */
  95. pmstate=STREAM(infile,'c','open read')
  96. IF pmstate<>'READY:' THEN DO
  97.   SAY 'Failed to open 'infile'... 'pmstate
  98.   EXIT
  99. END
  100. pmlength=STREAM(infile,'c','query size')
  101. pmrecs=pmlength/pmreclen
  102.  
  103. /* Open PMCOMM.LST, scratch if exists */
  104. ofstate=STREAM(outfile,'c','open write')
  105. IF ofstate<>'READY:' THEN DO
  106.   SAY 'Failed to open 'outfile'... 'ofstate
  107.   EXIT
  108. END
  109. ofstate=STREAM(outfile,'c','seek =1')
  110.  
  111. SAY 'Creating 'outfile' from 'infile'...'
  112.  
  113. /* Get records and do translations */
  114. DO recnum=1 TO pmrecs BY 1
  115.   pmrecord=CHARIN(infile,,pmreclen)
  116.   CALL CHAROUT ,cr||'Processing record '||recnum
  117.   protocol=C2D(REVERSE(SUBSTR(pmrecord,72,2)),2)
  118.   SELECT
  119.     WHEN protocol=1 THEN fprotocol=234
  120.     WHEN protocol=2 THEN fprotocol=233
  121.     WHEN protocol=3 THEN fprotocol=228
  122.     WHEN protocol=4 THEN fprotocol=232
  123.     WHEN protocol=5 THEN fprotocol=230
  124.     OTHERWISE fprotocol=protocol
  125.   END
  126.   IF protocol=fprotocol THEN
  127.     CALL CHAROUT ,': no change    '
  128.   ELSE DO
  129.     CALL CHAROUT ,': '||protocol||' -> '||fprotocol||'   '
  130.     recsfixd=recsfixd+1
  131.   END
  132.   ofrecord=OVERLAY(REVERSE(D2C(fprotocol,2)),pmrecord,72,2)
  133.   ofstate=CHAROUT(outfile,ofrecord)
  134.   recsdone=recsdone+1
  135.   DO 1000 ; NOP /*look ma! 2fast!*/ ; END
  136. END
  137.  
  138. /* Close files and do some begging */
  139. pmstate=STREAM(infile,'c','close')
  140. ofstate=STREAM(outfile,'c','close')
  141. CALL CHAROUT ,cr'FIXPRT complete, 'recsdone' entries processed, '
  142. CALL CHAROUT ,recsfixd' repaired.'crlf
  143. SAY ' '
  144. SAY 'Thank you for using QMtoPM!  I hope you have found'
  145. SAY 'this software to be useful will consider registering.'
  146. SAY ' '
  147. SAY 'Brad Berson, ABC-TV, 47 W. 66th St., NY NY 10023'
  148. EXIP:
  149. EXIT
  150.  
  151. /* Error handler */
  152. ERRH:
  153.   SAY ' '
  154.   IF RC='RC' THEN
  155.     SAY 'REXX/2 ERROR in line 'sigl
  156.   ELSE
  157.     SAY 'REXX/2 ERROR 'rc' in line 'sigl': 'ERRORTEXT(rc)
  158.   SAY SOURCELINE(sigl)
  159.   SAY 'Condition: 'CONDITION('C')
  160.   SAY 'PROGRAM ABENDED.'
  161.   EXIT
  162.  
  163.