I have managed to read a file name and two strings. Now I need to search the file for a lines that maches string1 and replace them with string2. And I have no idea how to do that. Can anyone help me please.

Recommended Answers

All 5 Replies

what operating system ? what version assembly language? what assembler?

Essentually you have to open two files -- input file for input and result (output) file for output. In a loop, read a line from the input file, then write to the output file either the original file or the replacement. Finally close both files.

The version 80x88. OS Windows XP. And I have only one file not two.

One more question. What's the easiest way to read a line from file and compare it to a string.

The easiest way to compare two strings depends entirely upon your assembler.

Chances are though that you might do just as well to write it yourself. First you need to have a good 80x86 assembly opcode reference. Here's a good one I found on Google.

I recommend you check out the repe cmpsb string command. It is used to compare two strings for equality.

Also, listen to Ancient Dragon. He knows what he is talking about. Unless you know exactly what tricky stuff to do, you must do it as he suggested: read the source file while writing a new file. Once done, you can delete the source file and rename the new file to have the same name that the source file did, if you want.

Hope this helps.

Thanks everyone.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.