The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: ciapek on June 04, 2010, 05:49:34 PM

Title: Read from txt file
Post by: ciapek on June 04, 2010, 05:49:34 PM
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
Title: Re: Read from txt file
Post by: qWord on June 04, 2010, 05:55:02 PM
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
Title: Re: Read from txt file
Post by: jj2007 on June 04, 2010, 07:22:03 PM
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

Title: Re: Read from txt file
Post by: ciapek on June 05, 2010, 07:14:52 AM
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
Title: Re: Read from txt file
Post by: jj2007 on June 05, 2010, 07:36:44 AM
Post your current complete code, and you might get help. We are no good at guessing what you are doing.
Title: Re: Read from txt file
Post by: MichaelW on June 05, 2010, 08:00:53 AM
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.

Title: Re: Read from txt file
Post by: ciapek on June 06, 2010, 04:57:17 PM
Thanks for help, now program is complete. :bg