home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 3 Comm / 03-Comm.zip / NSC2IPF.ZIP / NSC2IPF.CMD next >
OS/2 REXX Batch file  |  1991-07-09  |  4KB  |  124 lines

  1. /* This REXX program will convert captured messages from
  2. IBM's National Support Center BBS into .IPF format.  This
  3. converted file can then be compiled with the IPFC compiler.
  4. by Dave Pinard 1991 */
  5.  
  6. PARSE ARG infile
  7. IF infile = "" THEN DO
  8.     Say 'Enter File Name to be Converted : '
  9.     Pull infile .
  10. END                            
  11. outfile = DATE('S')||".IPF"
  12. inffile = DATE('S')||".INF"
  13. QUEUE ":userdoc."
  14. QUEUE ":Title.IBM NSC BBS  -  "DATE('L')
  15. QUEUE ":body."
  16. res = 0
  17. DO WHILE lines( infile ) \= 0
  18.     origline = linein( infile )
  19.     msgbody = 1
  20.     IF origline \= "" THEN DO
  21.         templine=origline
  22.         CALL CONVERT_IT origline 
  23.         origline = result
  24.     END
  25.     PARSE VAR origline first text
  26.     IF first = '****' THEN DO
  27.         PARSE VAR text forum '****'
  28.         QUEUE ':H1.'||forum
  29.         CALL WRITEFILE
  30.         SAY 'Starting 'templine' conference.'
  31.         msgbody = 0
  32.     END
  33.     IF first = 'Message' THEN DO
  34.         PARSE VAR text '&colon.' msgno '(' forum ')' space 'Date...' '&colon.' date 
  35.         QUEUE first'&colon.'||msgno||'('forum')'||space||'Date...'||'&colon.'||date
  36.         msgbody = 0
  37.     END
  38.     IF first = 'From...' THEN DO
  39.         PARSE VAR text '&colon.' fname 'Refer..' '&colon.' refer
  40.         QUEUE first'&colon.'||fname||'Refer..'||'&colon. '||refer
  41.         msgbody = 0
  42.     END
  43.     IF first = 'To.....' THEN DO 
  44.         PARSE VAR text '&colon.' tname "Sec'ty." '&colon.' security 
  45.         QUEUE first'&colon.'||tname||"Sec'ty."||'&colon. '||security
  46.         msgbody = 0
  47.     END
  48.     IF first = 'Subject' THEN DO
  49.         res = res + 1
  50.         PARSE VAR text '&colon.' Subj "Rec'vd." '&colon.' received
  51.         PUSH ':xmp.'
  52.         PUSH ':H2 res='res+1'.'||'('||msgno||')  'Subj
  53.         PUSH ':link reftype=hd res='res+1'.Next MSG:elink.   :link reftype=hd res='res-1'.Previous MSG:elink.'
  54.         QUEUE first'&colon.'||subj||"Rec'vd."||'&colon. '||received
  55.         QUEUE ':exmp.'
  56.         CALL WRITEFILE
  57.         SAY 'MESSAGE #:'msgno'completed.'
  58.         msgbody = 0
  59.     END
  60.     IF origline = ' ' THEN DO
  61.         QUEUE ':p.'
  62.         CALL WRITEFILE
  63.     END
  64.     IF msgbody = 1 & origline \= ' ' THEN DO
  65.         QUEUE origline
  66.         CALL WRITEFILE
  67.     END
  68. END
  69. CALL LINEOUT outfile, ":euserdoc."
  70. CALL LINEOUT (outfile)
  71. SAY ' '
  72. SAY 'Procedure finished, 'outfile' created.'
  73. SAY ' '
  74. SAY 'Do you want to run the IPFC compiler?  (Y/N)'
  75. PULL answer
  76. IF answer \= 'Y' THEN DO
  77.     EXIT
  78. END
  79. ADDRESS  CMD "ipfc /inf" outfile
  80. SAY ' '
  81. SAY 'Do you want to VIEW this file?  (Y/N)'
  82. PULL answer1
  83. IF answer1 = 'Y' THEN DO
  84.     ADDRESS  CMD "view" inffile
  85. END
  86. SAY 'Do you want to DELETE' outfile'?  (Y/N)'
  87. PULL answer2
  88.     IF answer2 = 'Y' THEN DO
  89.         ADDRESS  CMD "del" outfile
  90.         /* ADDRESS CMD "del" infile */
  91.     END
  92. EXIT
  93.  
  94. /* Write out data in queue */
  95. WRITEFILE:
  96. DO WHILE QUEUED() > 0
  97.     PARSE PULL line
  98.     CALL LINEOUT outfile, line
  99. END
  100. RETURN
  101.  
  102. /* Convert & and : to &. and &colon. */
  103. CONVERT_IT: 
  104. PARSE ARG pass_line
  105. start_pos = 1
  106. found_pos = POS('&',pass_line,start_pos)
  107.  
  108. DO WHILE found_pos > 0
  109.     pass_line = INSERT('amp.',pass_line,found_pos)
  110.     start_pos = found_pos +5
  111.     found_pos = POS('&',pass_line,start_pos)
  112. END
  113.  
  114. start_pos = 1
  115. found_pos = POS(':',pass_line,start_pos)
  116.  
  117. DO WHILE found_pos > 0
  118.     pass_line = OVERLAY('&',pass_line,found_pos)
  119.     pass_line = INSERT('colon.',pass_line,found_pos)
  120.     start_pos = found_pos +7
  121.     found_pos = POS(':',pass_line,start_pos)
  122. END
  123. RETURN pass_line
  124.