Archive: Getting line number for spesific string from text file


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?


There are lots of functions in the Archive that help you do that. Try this one for example:

http://nsis.sourceforge.net/archive/...ances=0,11,311


This function will find a string in a file and tell you what line it is on:
http://nsis.sourceforge.net/archive/...15&instances=0

You can then use this script to actually replace the text on that line:
http://nsis.sourceforge.net/archive/...48&instances=0

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

-Stu


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.


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.


Thanks! I will try it.