2009-08-21 7 views

Répondre

1

Oui il y a. Vous pouvez utiliser un FLUX pour le faire.

/* Define a new named stream */ 
DEF STREAM myStream. 

/* Define the output location of the stream */ 
OUTPUT STREAM myStream TO VALUE("c:\text.txt"). 

/* Write some text into the file */ 
PUT STREAM myStream UNFORMATTED "Does this work?". 

/* Close the stream now that we're done with it */ 
OUTPUT STREAM myStream CLOSE. 
+1

STREAM est juste un mot-clé pour nommer un descripteur de fichier. Il ne "modifie" rien en soi. –

7

L'édition consiste à lire un fichier, en utilisant probablement IMPORT, manipuler ensuite le texte en utilisant les fonctions de chaîne comme REPLACE() et enfin écrire le résultat en utilisant probablement PUT. Quelque chose comme ceci:

define stream inFile. 
define stream outFile. 

define variable txtLine as character no-undo. 

input stream inFile from "input.txt". 
output stream outFile to "output.txt". 

repeat: 

    import stream inFile unformatted txtLine. 

    txtLine = replace(txtLine, "abc", "123"). /* edit something */ 

    put stream outFile unformatted txtLine skip. 

end. 

input stream inFile close. 
output stream outFile close. 
+0

+1 Nice! :-) – AquaAlex

0

Progress pourrait appeler éditeur de système d'exploitation:

OS-COMMANDE ("vi /tmp/yoyo.txt").

0

Vous pouvez utiliser LOB copie à lire et à écrire, je pense que pour « éditer » le fichier

DEF VAR lContents AS LONGCHAR NO-UNDO. 

/* read file */ 
COPY-LOB FROM FILE "ascii.txt" TO lContents. 
/* change Contents, e.g. all capital letters */ 
lContents = CAPS(lContents). 
/* save file */ 
COPY-LOB lContents TO FILE "ascii.txt". 
0

vous dire être capable de lire et puis afficher le fichier dans l'écran et de manipuler le fichier?

Si oui alors vous en avez un facile, bien sûr, la taille du fichier ne peut pas être plus grande que le max. la capacité d'une variable vchar:

def var fileline as char format "x(250)". /* or shorter or longer, up to you*/ 
def var filedit as char. 

/*you have to quote it to obtain & line into teh charvar*/ 

unix silent quoter kk.txt > kk.quoted. 

input from kk.quoted no-echo. 


repeat: 

    set fileline. 

    filedit = filedit + (fileline + chr(13) + chr(10)) . 

end. 

input close. 

update filedit view-as editor size 65 by 10. 

Bien sûr, vous pouvez gérer pour enregistrer le fichier une fois édité ;-)

Questions connexes