/* This genie pre-processes Doc files and other ASCII files. It breaks up long lines of ==== etc., converts double quotes, replaces formfeeds with the Pro Page "next box" code, and deals with PC and Mac line endings. Written by Don Cox, April '93. Not Public Domain. All rights reserved. */ trace n if ~show("l", "rexxsupport.library") then if ~addlib("rexxsupport.library", 0, -30,0) then do call ppm_Inform(1,"Please install the rexxsupport.library in your libs: directory before running this Genie.") end 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) 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 CR-LF with LF, for MSDOS files */ do forever position = pos("0d0a"x, text,position+1) if position = 0 then break text = delstr(text,position,1) end position = 0 /* now we can replace CR with LF, for Mac files */ do forever position = pos("0d"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 tabs with Mspace-tab, so that runs of tabs can be broken. */ do forever position = pos("09"x, text,position+1) if position = 0 then break text = delstr(text,position,1) text = insert("\127\s",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 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("\127\s",text,position-1) /* the \127 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,) call ppm_AutoUpdate(1) call ppm_ClearStatus() exit end