Skip to content
General IRCX

removing from a txt file

A TG007 community discussion started by Rhys.

Discussion 7 posts
Page 1 of 1
Open
Topic #2079 · 7 published posts · 1,519 views

i have a login bot a mate of mine (owner of Talk-Central) sent me, and i have added many features to it. i need help with a change password command. i need to change the 2nd word in a text document. an example is below in a text document

 

Username Password OpType OpPermission is how its set out, eg:

 

rhys pass +q 1

bob test +o 2

 

etc...

 

i need help changing it to whatever the user says.

The -l# switch specifies the line number where the text is to be written.

 

/write -l5 c:\info.txt This line will overwrite the 5th line in the file

 

The above command will delete the 5th line in the file.

 

The -s# switch scans a file for the line beginning with the specified text and performs the operation on that line.

 

/write -dstest c:\info.txt

 

This will scan file info.txt for a line beginning with the word "test" and if found, deletes it.

 

thats not really what i was looking for.

You can't replace a specific part of a specified line; you can only replace the whole line.

 

oh ok thaks

oh ok thaks

only way to replace a section in the line is by reading that line first, setting it to a variable, replacing what you want in that variable, and then writing that back over the line.

 

example:

 

alias txtrepex {
var %filename $?="Please enter the directory to the file in which you want to replace" 
var %linetoreplace $?="Please enter the line number in which you want to replace"
var %readingline $read(%filename,%linetoreplace)
var %toreplace $?="What would you like to replace in the line"
var %afterreplace $?="and the replacement is"
var %enterline $replace(%readingline,%toreplace,%afterreplace)
/write %filename -l $+ %linetoreplace %enterline
}

 

 

this example is very basic, and can be done in a lot less lines if you know what you are doing. try and read through this, and see how it works.

k thanks for the reply's everyone.