hello peoples
can your help me with bypass chars in file?
my source is added
thanks
remus
[attachment deleted by admin]
remus2k,
It looks like you need to set up a loop so that you can fill the display buffer. If I add a sentence to the beginning of test.txt a messagebox will pop up showing the first character just as it should. Then the empty dialog box appears.... what's up with that? Just what do you want to do? Do you want to display what is in text.txt except for commented lines?
Paul
What your code currently does is read ONE character from the file and then show a messagebox if it's not '-'
We can guess at what you're trying to do, but whatever it is, you'll probably need to read more characters than just the first one :wink
Change the call to ReadFile to:
invoke ReadFile, hFile,addr hBuffer,SIZEOF hBuffer,addr NumberOfBytes,NULL
and that will read up to 255 characters from the file (all of the file if it is smaller.)
Then what you need to do is increase the pointer (edi) to move onto the next character, so you can check what it is.
If you want to remove '-' characters, then you'll need to copy the characters that don't match into a new buffer, so you can print them when you've got them all.
thanks for your help first times :U
I do not want that it am in such a way indicated each stringer in messagesbox am indicated
I have much try out I do not understand that!
can help their me still times please?
invoke CreateFile,offset szFile,GENERIC_READ or GENERIC_WRITE,\
FILE_SHARE_READ or FILE_SHARE_WRITE,0,\
OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0
mov hFile,eax
invoke GetFileSize,eax,NULL
invoke ReadFile, hFile,addr hReadBuffer,SIZEOF hReadBuffer,addr NumberOfBytes,NULL
mov esi, offset hReadBuffer ; esi = beginning of the string
xor ecx, ecx ; ecx = 0
@read:
cmp BYTE PTR [esi], '-' ; [esi] == [-]
jne @1 ; TRUE: jump to @1
jmp @ret
@1:
inc esi
mov edi,esi
cmp BYTE PTR [esi], '-' ; [esi] == [-]
je @Print
@Print:
invoke MessageBox,hWnd,edi,NULL,MB_OK
jmp @read
@ret:
greets
remus2k
You want..
"-test1-test2-test3-" ==>
MessageBox("test1")
MessageBox("test2")
MessageBox("test3")
??
I become times example search
yes Tedd that is this what i want
So, you need TWO buffers - one to read the file into, and the other to copy the string characters into (so you can show them in the messageox)
Steps:
- open file; read file (into buffer1); close file
*loop:
- parse string, looking for '-' (from buffer1)
- when found, copy characters from buffer1 into buffer2, until you find another '-' (or end of file data)
- show messagebox for buffer2
- get character at current position in buffer1, if '-' then loop, else finish
thanks :wink
i hope that“s works
ragdog
Make sure you terminate buffer2 with a 0 before you display the text. You should clear the buffer between writes, also. It does not matter in this example as the 3 strings are the same size but it is good to develop certain habits.
Paul
Another option besides what Tedd wrote (which is a better choice) is to just NULL terminate the chars you don't want to be displayed. Then you already have a NULL terminated string to display and can just advance a pointer to the start of the next display string.
Relvinian
Quote from: Relvinian on December 08, 2006, 03:11:20 AM
Another option besides what Tedd wrote (which is a better choice) is to just NULL terminate the chars you don't want to be displayed. Then you already have a NULL terminated string to display and can just advance a pointer to the start of the next display string.
This is true, though it is destructive. In this instance it doesn't really matter, but it's not generally a good practice.
hi remus
here is your workig code :U
[attachment deleted by admin]
Quote from: Tedd on December 08, 2006, 01:39:28 PM
Quote from: Relvinian on December 08, 2006, 03:11:20 AM
Another option besides what Tedd wrote (which is a better choice) is to just NULL terminate the chars you don't want to be displayed. Then you already have a NULL terminated string to display and can just advance a pointer to the start of the next display string.
This is true, though it is destructive. In this instance it doesn't really matter, but it's not generally a good practice.
You are correct...It all depends on the situation you are designing for. Some buffers can be used as destructive while others can't. That's left up to the programmer of said functions.
Relvinian
i have drouble with copy string in register
i will not use lstrcat algo
can your help me thats the string copy in the register“s
my source is posted
greetz ragdog
[attachment deleted by admin]
I created it so far
as I delete the last character ( - ) into my string
invoke CreateFile,offset szFile,GENERIC_READ or GENERIC_WRITE,\
FILE_SHARE_READ or FILE_SHARE_WRITE,0,\
OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0
mov hFile,eax
invoke ReadFile, hFile,addr hRead,sizeof hRead,addr NumberOfBytes,0
mov edi, offset hData
mov esi, offset hRead
mov ebx,0
@@:
mov al, byte ptr [esi] ; read byte
mov byte ptr [edi], al ; write byte
cmp al,"-" ; did we copy a null?
je @print ; done
inc esi ; else increment pointers using INC
inc edi
jmp @B
@print:
mov edi,offset hData
invoke MessageBox,hWnd,offset hData,0,MB_OK
inc esi
inc ebx
cmp ebx,3
jne @B
ragdog
jmp @B
@print:
mov BYTE PTR [edi],0 ; <------- ADD ME!!!
mov edi,offset hData
:U
RagDog,
As Tedd has said (without saying it), you did not zero terminate the buffer. You need to do this before you can use the buffer in , for example, a MessageBox.
BTW: That is an interesting choice of an avatar...
Paul
thank tedd this works :U
and paul for the info
regards
ragdog