/* @BTraitementFichierASCII @P @I Ecrit et © Don Cox avril 1993 @IN'est pas du Domaine Publique. Tous Droits Réservés. Traduit et modifié par Fabien Larini le 29/07/93. Ce Génie permet de traiter un fichier ASCII afin d'éviter certains problèmes. Ce Génie convertit les sauts de pages en boîte suivante, les retourschariots-sautsdeligne en sautsdeligne, ... Ce Génie sauve le résultat dans le même répertoire et le même nom plus le suffixe .proc que le fichier de départ. */ /*ASCIIFileProcessor*/ /* 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', "gdarexxsupport.library") then if ~addlib("gdarexxsupport.library",0,-30) then call exit_msg("Installez la gdarexxsupport.library dans le répertoire libs: avant de lancer ce Génie") call SafeEndEdit.rexx() call ppm_AutoUpdate(0) address command filename = ppm_GetFileName("Fichier Texte à Traiter", "", "") if filename = '' then call exit_msg("Pas de Fichier Choisi") if ~open("input",filename,"R") then call exit_msg("Ne peus pas Lire le fichier") filelength = word(statef(filename),2) fileblocks = (filelength % 10000)+1 filename2 = filename||".proc" if ~open("output",filename2,"W") then call exit_msg("Ne peus pas Ecrire le Fichier") blocknumber = 1 do until eof("input") text = readch("input",10000) call ppm_ShowStatus("Traitement en cours sur le Bloc "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(" \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(" \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 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("Terminé") /* * 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