This genie pre-processes files from the Sharp word-processor. It gets rid of the more numerous codes, but leaves the garbage at the start and end to be deleted manually.
Written by Don Cox, April '93. Not Public Domain. All rights reserved.
Sharp version March 94
*/
trace n
call SafeEndEdit.rexx()
call ppm_AutoUpdate(0)
address command
filename = ppm_GetFileName("Open Text File:", "", "")
if filename = '' then call exit_msg("No File Selected")
if ~open("input",filename,"R") then call exit_msg("Could not open input file")
filelength = word(statef(filename),2)
fileblocks = (filelength % 10000)+1
filename2 = filename||".proc"
if ~open("output",filename2,"W") then call exit_msg("Could not open output file")
blocknumber = 1
do until eof("input")
text = readch("input",10000)
call ppm_ShowStatus(" Processing block "blocknumber" of "fileblocks)
/* remove header */
tlength = length(text)
if blocknumber = 1 then text = right(text,tlength-432)
blocknumber = blocknumber +1
position = 0 /* replace formfeeds with "next box" command */
do forever
position = pos("0c"x, text,position+1)
if position = 0 then break
text = delstr(text,position,1)
text = insert("\!",text,position-1)
end
position = 0 /* replace 1E with £ */
do forever
position = pos("1E"x, text,position+1)
if position = 0 then break
text = delstr(text,position,1)
text = insert("£",text,position-1)
end
position = 0 /* replace B2 with " */
do forever
position = pos("B2"x, text,position+1)
if position = 0 then break
text = delstr(text,position,1)
text = insert("22"x,text,position-1)
end
position = 0 /* now replace left double quotes after spaces */
do forever
position = pos(" "||"22"x, text,position+1)
if position = 0 then break
text = delstr(text,position,2)
text = insert(" "||"b9"x,text,position-1)
end
position = 0 /* now replace left double quotes after linefeeds */
do forever
position = pos("0a22"x, text,position+1)
if position = 0 then break
text = delstr(text,position,2)
text = insert("0ab9"x,text,position-1)
end
position = 0 /* now replace right double quotes */
do forever
position = pos("22"x, text,position+1)
if position = 0 then break
text = delstr(text,position,1)
text = insert("b2"x,text,position-1)
end
/* Remove codes 83 & D6 */
text = compress(text,"83"x)
text = compress(text,"D6"x)
position = 0 /* now remove single line endings */
do forever
position = pos("81BA"x, text,position+1)
if position = 0 then break
text = delstr(text,position,2)
text = insert(" ", text,position-1)
end
position = 0 /* now remove odd codes */
do forever
position = pos("B1"x, text,position+1)
if position = 0 then break
text = delstr(text,position,1)
text = insert("0a"x, text,position-1)
end
position = 0 /* now replace hard line-end codes */
do forever
position = pos("81B9"x, text,position+1)
if position = 0 then break
text = delstr(text,position,2)
text = insert("0a"x,text,position-1)
end
position = 0 /* now replace double line-end codes */
do forever
position = pos("0a0a"x, text,position+1)
if position = 0 then break
text = delstr(text,position,2)
text = insert("0a"x,text,position-1)
end
position = 0 /* now replace tab codes */
do forever
position = pos("81c9"x, text,position+1)
if position = 0 then break
text = delstr(text,position,1)
text = insert("09"x,text,position-1)
end
position = 0 /* now replace odd codes */
do forever
position = pos("C1"x, text,position+1)
if position = 0 then break
text = delstr(text,position,1)
text = insert("**",text,position-1)
end
position = 0 /* replace sets of 4 spaces with tabs */
do forever
position = pos(" ", text,position+1)
if position = 0 then break
text = delstr(text,position,4)
text = insert(" \s",text,position-1) /* the space allows long strings of tabs to be broken */
end
position = -3 /* break up rows of ===== */
do forever
position = pos("====", text,position+4)
if position = 0 then break
text = delstr(text,position,4)
text = insert("== =",text,position-1)
end
position = -3 /* break up rows of ++++ */
do forever
position = pos("++++", text,position+4)
if position = 0 then break
text = delstr(text,position,4)
text = insert("++ +",text,position-1)
end
position = -3 /* break up rows of **** */
do forever
position = pos("****", text,position+4)
if position = 0 then break
text = delstr(text,position,4)
text = insert("** *",text,position-1)
end
position = -3 /* break up rows of ~~~~ */
do forever
position = pos("~~~~", text,position+4)
if position = 0 then break
text = delstr(text,position,4)
text = insert("~~ ~",text,position-1)
end
call writech("output",text)
end
call exit_msg("Done")
/*
* Exit Msg Procedure
*/
exit_msg: procedure
do
parse arg message
if message ~= '' then call ppm_Inform(1, message,)