Skip to content
⌘ NSIS Forum Archive

Getting line number for spesific string from text file

6 posts

edwinyn#

Getting line number for spesific string from text file

I have to replace a string from a text file, but I have to know its line number. How can I do that?
kichik#
There are lots of functions in the Archive that help you do that. Try this one for example:

Afrow UK#
This function will find a string in a file and tell you what line it is on:


You can then use this script to actually replace the text on that line:


The last one I wrote for the sake of this (was bored too).

-Stu
deguix#
I have a suggestion:

Have the command FileReadByte, right? It returs a number 1-255 as the character in ANSII. Maybe adding a option to don't convert the character to a number, (meaning as it is). I can use the FileRead, but it doesn't return the Enter key characters.
kichik#
FileRead does return \n and \r. You can use FileRead's maxlen parameter to make it act like FileReadByte, only without the conversion to a number.