This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

find and replace (tcl)

Old posts that have not been replied to for several years.
Locked
B
Black

Post by Black »

what is the best method for tcl scripting to find a specific position and replace it in an saved file which consists of few lines.

would be nice if someone can reply an complete example for this, the "7" is to be replaced:

1;2;3;4
5;6;7;8
9;10;11;12


thx
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Read in the file, split it with 'split', and then use lsearch and lreplace to find and replace it. Then rewrite the file with the new data.

If you're only using that file to store date you use in your script, there are other file formats that would make the process easier.
Locked