hello all;
what i want to do is read only first or second line of a file
then *cmp* it to the one that is already inputed by the user.
but i am fine with *cmp* how can i read part of a file.
i am guessing i have to build a parser to search the file ....
which i cant maybe next year
if i dont need a parser plz help
Posted on 2002-07-07 01:46:34 by b0z0
Yes, you need to parse the file.

1. Read the contents of a file into the first buffer
2. be ready with the second buffer.
3. Copy the contents of the first buffer into the second buffer until you hit a character 0Dh. Instead of copying 0Dh into the 2nd buffer append 0.
4. use strcmp or lstrcmp to compare strings
5. starting from where you left off on the first buffer, go back to step 3.

Remember to ignore 0Dh and 0Ah...

Here's a modified version of my strtok...this will help you, reading the buffer line by line. And not only that, you can customize it. Just add a couple of cmp and the characters you want to ignore


mov dl, BYTE PTR [esi+ecx]
or dl, dl
cmp dl, 0Dh
You can insert your code here. :)

At the SendMessage parts, you can insert your strcmp ......

This isn't exactly what you want but the procedure there would help you understand how it is done. :)
Posted on 2002-07-07 02:04:30 by stryker
thx stryker
i am not a assembly guru yet but i'll try to understand as much as possible then come up with something of my own, if i cant :(
Posted on 2002-07-07 09:39:55 by b0z0
There's always room for improvements...my strtok is just a "generic parser" in which I can customize it in anyway I wanted it too. If you just want to get the first line, do something like this:
mov eax, OFFSET buffer1

xor ecx, ecx
mov edx, OFFSET buffer2

mov bl, BYTE PTR [eax+ecx]
.IF (bl != 0 || bl != 0Dh)
mov BYTE PTR [edx+ecx], bl
jmp @F
inc ecx
jmp @B
mov BYTE PTR [edx+ecx], 0
Basically, this is how you do it, though not tested.

1. Setup the registers before the loop
2. copy a byte from the first buffer into bl.
3. Check if bl == 0 or bl == 0Dh
4. If it's equal exit.
5. if not copy bl into the second buffer
6. increment ecx
7 jump back to step 2
8. at exit, buffer2 now has the first line of strings.


(code above not tested)
Posted on 2002-07-07 11:17:07 by stryker
thx stryker
Posted on 2002-07-07 11:21:00 by b0z0