home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 3 Comm
/
03-Comm.zip
/
NSC2IPF.ZIP
/
NSC2IPF.CMD
next >
Wrap
OS/2 REXX Batch file
|
1991-07-09
|
4KB
|
124 lines
/* This REXX program will convert captured messages from
IBM's National Support Center BBS into .IPF format. This
converted file can then be compiled with the IPFC compiler.
by Dave Pinard 1991 */
PARSE ARG infile
IF infile = "" THEN DO
Say 'Enter File Name to be Converted : '
Pull infile .
END
outfile = DATE('S')||".IPF"
inffile = DATE('S')||".INF"
QUEUE ":userdoc."
QUEUE ":Title.IBM NSC BBS - "DATE('L')
QUEUE ":body."
res = 0
DO WHILE lines( infile ) \= 0
origline = linein( infile )
msgbody = 1
IF origline \= "" THEN DO
templine=origline
CALL CONVERT_IT origline
origline = result
END
PARSE VAR origline first text
IF first = '****' THEN DO
PARSE VAR text forum '****'
QUEUE ':H1.'||forum
CALL WRITEFILE
SAY 'Starting 'templine' conference.'
msgbody = 0
END
IF first = 'Message' THEN DO
PARSE VAR text '&colon.' msgno '(' forum ')' space 'Date...' '&colon.' date
QUEUE first'&colon.'||msgno||'('forum')'||space||'Date...'||'&colon.'||date
msgbody = 0
END
IF first = 'From...' THEN DO
PARSE VAR text '&colon.' fname 'Refer..' '&colon.' refer
QUEUE first'&colon.'||fname||'Refer..'||'&colon. '||refer
msgbody = 0
END
IF first = 'To.....' THEN DO
PARSE VAR text '&colon.' tname "Sec'ty." '&colon.' security
QUEUE first'&colon.'||tname||"Sec'ty."||'&colon. '||security
msgbody = 0
END
IF first = 'Subject' THEN DO
res = res + 1
PARSE VAR text '&colon.' Subj "Rec'vd." '&colon.' received
PUSH ':xmp.'
PUSH ':H2 res='res+1'.'||'('||msgno||') 'Subj
PUSH ':link reftype=hd res='res+1'.Next MSG:elink. :link reftype=hd res='res-1'.Previous MSG:elink.'
QUEUE first'&colon.'||subj||"Rec'vd."||'&colon. '||received
QUEUE ':exmp.'
CALL WRITEFILE
SAY 'MESSAGE #:'msgno'completed.'
msgbody = 0
END
IF origline = ' ' THEN DO
QUEUE ':p.'
CALL WRITEFILE
END
IF msgbody = 1 & origline \= ' ' THEN DO
QUEUE origline
CALL WRITEFILE
END
END
CALL LINEOUT outfile, ":euserdoc."
CALL LINEOUT (outfile)
SAY ' '
SAY 'Procedure finished, 'outfile' created.'
SAY ' '
SAY 'Do you want to run the IPFC compiler? (Y/N)'
PULL answer
IF answer \= 'Y' THEN DO
EXIT
END
ADDRESS CMD "ipfc /inf" outfile
SAY ' '
SAY 'Do you want to VIEW this file? (Y/N)'
PULL answer1
IF answer1 = 'Y' THEN DO
ADDRESS CMD "view" inffile
END
SAY 'Do you want to DELETE' outfile'? (Y/N)'
PULL answer2
IF answer2 = 'Y' THEN DO
ADDRESS CMD "del" outfile
/* ADDRESS CMD "del" infile */
END
EXIT
/* Write out data in queue */
WRITEFILE:
DO WHILE QUEUED() > 0
PARSE PULL line
CALL LINEOUT outfile, line
END
RETURN
/* Convert & and : to &. and &colon. */
CONVERT_IT:
PARSE ARG pass_line
start_pos = 1
found_pos = POS('&',pass_line,start_pos)
DO WHILE found_pos > 0
pass_line = INSERT('amp.',pass_line,found_pos)
start_pos = found_pos +5
found_pos = POS('&',pass_line,start_pos)
END
start_pos = 1
found_pos = POS(':',pass_line,start_pos)
DO WHILE found_pos > 0
pass_line = OVERLAY('&',pass_line,found_pos)
pass_line = INSERT('colon.',pass_line,found_pos)
start_pos = found_pos +7
found_pos = POS(':',pass_line,start_pos)
END
RETURN pass_line