News:

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

Read from txt file

Started by ciapek, June 04, 2010, 05:49:34 PM

Previous topic - Next topic

ciapek

Hello Everyone!
I want to check if the character is space.
First, I open txt file and the length of it. Next, I want to counter the number of spaces, and I dont know how.

mov eax, pointer      ;pointer on the start of file       
            mov ecx, pointer      ;pointer on the start of file
            add ecx, sizeoffile       ;add size of file to pointer
            xor edx, edx           ;reset edx
       

                .WHILE TRUE
                    mov ebx, ds:[eax]               ;move to ebx address of first character           
                       .IF (eax == 20h)             ;check if space, not working
                            inc edx                 ;if yes add 1 to edx
                       .ENDIF
                    mov ds:[eax], ebx
                    inc eax                         ;next character
                    .BREAK .IF (eax == ecx)
                .ENDW


This is only small part of my program, which should crypt the txt file.
Thanks for help

qWord

it should be:
               .WHILE eax != ecx
                    movzx ebx, BYTE ptr ds:[eax]    ;move byte with zero extension to ebx           
                       .IF (ebx == 20h)             ;check if space, not working
                            inc edx                 ;if yes add 1 to edx
                       .ENDIF
                    ;mov ds:[eax], ebx
                    inc eax                         ;next character
                .ENDW
FPU in a trice: SmplMath
It's that simple!

jj2007

Or, even shorter:
               .WHILE eax != ecx
                       .IF BYTE ptr [eax] == 20h
                            inc edx                 ;if yes add 1 to edx
                       .ENDIF
                    inc eax                         ;next character
                .ENDW


ciapek

Thanks for help, program works.
But I have another problem with buttons and text on them. I write using prostart and I don't know where to find place to write the text into the buttons.
Really, this is last question.
Thanks for help

jj2007

Post your current complete code, and you might get help. We are no good at guessing what you are doing.

MichaelW

Quote from: ciapek on June 05, 2010, 07:14:52 AM
I write using prostart and I don't know where to find place to write the text into the buttons.

If by buttons you mean the toolbar buttons, I think you are supposed to supply a bitmap that contains the button images. For an example see \masm32\examples\poasm\riched, file2000.bmp, rsrc.rc, and toolbar.asm.

eschew obfuscation

ciapek

Thanks for help, now program is complete. :bg