Trying to use readfile to Replace some text in a file. I know how to do it with the ReadLN function but its so extremely slow I just can't use it. I need to be able to read a file and if a certain text is in the file then do something. but the text I need to find is on three lines.
Example
TYPEID_GAMEOBJECT_BETA3_WM
GAMEOBJECT_FACING
TYPEID_GAMEOBJECT_BETA3_WM
that is the text I need to find and replace it with
TYPEID_GAMEOBJECT_BETA3_WM
is there ANY function that will read a file and have the ability to read each line of the file instead of one long string?
Also what is the characters between the two lines? is it a CR?
Readfile Question
Moderators: JRL, Dorian (MJT support)
Between each lines will be a carriage return and linefeed -CRLF.
So you might just be able to do this:
Let>needle=TYPEID_GAMEOBJECT_BETA3_WM%CRLF%GAMEOBJECT_FACING%CRLF%TYPEID_GAMEOBJECT_BETA3_WM
Let>replacement=TYPEID_GAMEOBJECT_BETA3_WM
ReadFile>filename,buffer
StringReplace>buffer,needle,replacement,buffer
Then write out the buffer to a new file with WriteLn (and delete and replace old file with new file if required).
So you might just be able to do this:
Let>needle=TYPEID_GAMEOBJECT_BETA3_WM%CRLF%GAMEOBJECT_FACING%CRLF%TYPEID_GAMEOBJECT_BETA3_WM
Let>replacement=TYPEID_GAMEOBJECT_BETA3_WM
ReadFile>filename,buffer
StringReplace>buffer,needle,replacement,buffer
Then write out the buffer to a new file with WriteLn (and delete and replace old file with new file if required).
MJT Net Support
[email protected]
[email protected]