Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

How do i remove a character from a .txt file


3 replies to this topic

Adam

Adam
  • Members
  • 107 posts

Posted 19 April 2002 - 00:51

hi all,


Have a problem i need help with asap.

Say i have a file on the end users machine. foo.txt

In this file are like 6 lines

#define blah
#define boo
#define jediknight2isawsome
#define goo
#define woo
#define black

I have a "addon" install that will have to go into a txt file and remove the "#" sign in front of a define.

I cant seem to find out how to do this. And I cant use the command that searches by Line numbers, as the line numbers my change..

Is there a command that i can give say "#define goo" and it will find that line and let me replace/remove/add a character?

Can anyone help?



Taco Bell

Taco Bell

    IS6 Expert

  • Moderators
  • 1,281 posts

Posted 19 April 2002 - 01:09

No, IS doesn't have a direct find/replace of text file content.

Therefore, you'll probably have to resort to reading in the file line by line,  modifying the line if necessary, and writing the new line back out a temp file.  Once you've exhausted all the lines, delete the original file and rename the temp one to match the original.
user posted image

EberhardH

EberhardH
  • Members
  • 137 posts

Posted 19 April 2002 - 07:31

Hi,

please have a look at this (zipped) script:
              filestrreplace.zip

You'll find it here at http://www.installsite.org
Navigate to "IS5/6 Samples" --> "Components and Files".

Eberhard

Adam

Adam
  • Members
  • 107 posts

Posted 19 April 2002 - 20:58

Thanks EberhardH, thats exatly what i needed.