News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

help with bypass chars in file

Started by remus2k, December 06, 2006, 07:53:01 PM

Previous topic - Next topic

remus2k

hello peoples

can your help me with bypass chars in file?

my source is added

thanks

remus

[attachment deleted by admin]

PBrennick

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
The GeneSys Project is available from:
The Repository or My crappy website

Tedd

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.
No snowflake in an avalanche feels responsible.

remus2k

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

Tedd

You want..

"-test1-test2-test3-" ==>

    MessageBox("test1")
    MessageBox("test2")
    MessageBox("test3")

??
No snowflake in an avalanche feels responsible.

ragdog


remus2k


Tedd

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
No snowflake in an avalanche feels responsible.

ragdog

thanks :wink

i hope thatĀ“s works

ragdog

PBrennick

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
The GeneSys Project is available from:
The Repository or My crappy website

Relvinian

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

Tedd

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.
No snowflake in an avalanche feels responsible.

ragdog

hi remus

here is your workig code :U

[attachment deleted by admin]

Relvinian

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

ragdog

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]