[Gambas-user] Edit a text file?

werner 007 admin at ...1080...
Tue Aug 26 23:36:41 CEST 2008


Hi Hamish

Not really sure  what you mean, but..
you need to open the file, find the position "Depends:" change the text
until position "Description" and save it.
There are many possibilities to do it with Gambas, look at the help (open,
input, read, print and so on).
A solution could also be to manipulate with arrays:

DIM content1 AS String[]
DIM content2 AS String[]
DIM row1 AS String
DIM row2 AS String
content1 = Split(File.Load("YourFile"), "\n")  'load textfile in array
FOR EACH row1 IN content                        ' and loop trough
  IF LEFT(row1,8)="Depends:"  then          ' position to change
    content2=Split(MID(row1,8),",")           ' load the parts
    for EACH row2 in content2                  ' loop to manipulate
         row2 = left(row2,instr(row2,"_")-1)   ' cut version info
    NEXT
    row1="Depends: " & JOIN(content2,",")              ' put it together
  end if
NEXT
OPEN "YourFile" FOR CREATE AS #FileID           ' create file
PRINT #fileID, JOIN(content,"\n")                   ' write 
CLOSE #fileID

Wrote this out of my head, so you would need to correct many things. Meant
only as idea. 
Anyway i would prefer to use the  file stream object and read/write direct
to it.

Regards, Werner(007)



-- 
View this message in context: http://www.nabble.com/Edit-a-text-file--tp19162815p19170893.html
Sent from the gambas-user mailing list archive at Nabble.com.





More information about the User mailing list