Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    May 2009
    Posts
    2

    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.

  2. #2
    Join Date
    Oct 2007
    Location
    Gensokyo
    Posts
    1,324
    Quote Originally Posted by Den View Post
    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.

    Code:
    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

  3. #3
    Join Date
    Jan 2001
    Location
    Anderson Island, WA, USA
    Posts
    2,863
    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.


    (Click here to contact me)
    Providing Independent Professional Consulting Services for
    IndigoRose products, World Wide.
    Located in -8:00 (-7:00 DST) GMT Timezone (Western United States)

  4. #4
    Join Date
    May 2009
    Posts
    2

    That work perfectly!!!

    Thanks you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts