home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 1: Amiga
/
FrozenFish-Apr94.iso
/
bbs
/
alib
/
d9xx
/
d952
/
machv.lha
/
MachV
/
GuideToText.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1993-12-31
|
2KB
|
96 lines
/* This ARexx program strips a filenamme.guide file of @Node, @EndNode
* @Next, @Prev and @Toc tokens. It also takes a line in the form
*
* @{"gadget text" Link GadgetInfo}
*
* and changes it to:
*
* gadget text.
*
* A formfeed is inserted every 60 lines. This can be changed on the command
* line.
*
* This program is REAL slow, but you can modify it easily to do more or
* less.
*
*
* Usage is: GuideToText file.guide
*
* The resulting file will be named file.guide.txt.
*
*/
parse arg filename lines_per_page
signal on ioerr
if filename = '?' then do
Say 'Usage: GuideToText file.guide [lines per page]'
Return 0
end
outfile = filename || '.txt'
if (lines_per_page == "") then
lines_per_page = 60
if Open(if,filename,'R') then do
if Open(of,outfile,'W') then do
Call stripit()
Call Close(of)
end; else
Say 'Cannot open ' outfile .
Call Close(if)
end; else
Say 'Cannot open ' || filename .
Return 0
stripit:
say "processing... (be patient, this is ARexx!)"
say "Press Ctrl-C to Abort!"
linecnt = 0
page_num = 1
/*lf = bitclr('4c'x,6) */
lf = '0c'x
do until eof(if)
l = ReadLN(if)
p = Pos('@',l) /* amigaguide token? */
skip_line = 0
if p ~= 0 then do
p = Pos('@{"',l) /* gadget? */
if p ~= 0 then do
l=DelStr(l,p,3) /* delete @{" */
p1 = Pos('" Link',l) /* find Link keyword */
if p1 ~= 0 then do
p2 = Pos('}',l,p1) /* find position of } */
if p2 ~= 0 then do
l = DelStr(l,p1,(p2-p1)+1) /* delete Link function} */
end
end
end; else do
p = Pos('@Node',l) | Pos('@EndNode',l) | Pos('@Next',l) | Pos('@Prev',l) | Pos('@Toc',l)
if p ~= 0 then
skip_line = 1 /* don't write this line */
end
end
if ~skip_line then do
Call WriteLN(of,l)
linecnt = linecnt + 1
if (linecnt > lines_per_page) then do
Call WriteLN(of,lf)
linecnt = 0;
say Page page_num
page_num = page_num + 1
end
end
end
Return 0
ioerr:
say IO Error
exit