View Full Version : Working with text file
Hello.
I have text.txt with some information
123
222
444
Mike
....
....
222
Tom
111
How can i replace Mike to Nick in this file (text.txt) when i click on next button.
ShadowUK
06-03-2009, 11:27 PM
Hello.
I have text.txt with some information
123
222
444
Mike
....
....
222
Tom
111
How can i replace Mike to Nick in this file (text.txt) when i click on next button.
Wrote for AMS, might work in SF8.
local Contents = TextFile.ReadToString("path\\text.txt");
local NewContents = String.Replace(Contents, "Mike", "Nick", 1, false);
TextFile.WriteFromString("path\\text.txt", NewContents, false);
I didn't open AMS or check the help file so I'm not sure I used the right syntax for String.Replace, I'm so used to the PHP String.Replace. :P
jassing
06-04-2009, 03:29 AM
Note that using the textfile route, if the other information might contain other data,such as "He mikes his own amp" instead of "444" you'll end up with "he Nicks his own amp" and Mike will remain.
vBulletin® v3.8.4, Copyright ©2000-2010, Jelsoft Enterprises Ltd.