News:

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

Using the OpenFileDlg Macro

Started by Robert Collins, January 10, 2005, 07:15:47 PM

Previous topic - Next topic

Robert Collins

The following macro is defined in \masm32\macros\macors.asm

      OpenFileDlg MACRO hWin,hInstance,lpTitle,lpPattern
        invoke OpenFileDialog,hWin,hInstance,reparg(lpTitle),reparg(lpPattern)
        EXITM <eax>
      ENDM


Snippit from my program is:

.486                                ; create 32 bit code
.model flat, stdcall             ; 32 bit memory model
option casemap :none       ; case sensitive

include \masm32\include\windows.inc
include \masm32\include\masm32.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\oleaut32.inc
include \masm32\include\comctl32.inc   
include \masm32\include\comdlg32.inc   

includelib \masm32\lib\masm32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\oleaut32.lib
includelib  \masm32\lib\comctl32.lib   
includelib  \masm32\lib\comdlg32.lib 

include \masm32\macros\macros.asm




.data
CaptionText        db   "Open File",0

szFilter               db  "All files *.*",0,"*.*",0,
                              "Text files *.txt",0,"*.txt",0,
                              "Assembly files *.asm",0,"*.asm",0,
                              "Resource files *.rc",0,"*.rc",0,0

.code
start:
  '
  '
  OpenFileDlg 0, 0, addr CaptionText, addr szFilter                         ;Does not assemble, has error A2008

  invoke OpenFileDialog, 0, 0, addr CaptionText, addr szFilter           ;Assembles OK
  '
  '


The second line, invoke OpenFileDialog,............................... is in the MACRO OpenFileDlg. During assembly MASM complains about the OpenFileDlg with an error message A2008: syntax error : OpenFIleDlg.

But, the second line assembles OK.

What is wrong with my usage of the macro?

Robert Collins

OK, it turns out that the problem seems to be because of the following:

EXITM <eax>

If  I comment out the <eax> part, so as to have

EXITM  ;<eax>

the macro assembles correctly and it works. So, what is going on here? I see many macros in the macros.asm file that have EXITM <someitem>. I know what the purpose of the <someitem> is but why is it causing a compile error?   


QvasiModo

They are macros that return a value. For example, this:
mov MyVar, OpenFileDlg(hWin, hInstance, offset szTitle, offset szPattern)
will produce:
invoke OpenFileDialog,hWin,hInstance,reparg(offset szTitle),reparg(offset szPattern)
mov MyVar,eax

Hope that helps! :)

Robert Collins

Quote from: QvasiModo on January 10, 2005, 11:15:41 PM
They are macros that return a value. For example, this:
mov MyVar, OpenFileDlg(hWin, hInstance, offset szTitle, offset szPattern)
will produce:
invoke OpenFileDialog,hWin,hInstance,reparg(offset szTitle),reparg(offset szPattern)
mov MyVar,eax

Hope that helps! :)

Nope, doesn't help at all. I already know what it implies, what I want to know is why does EXIT <eax> cause a compile error. 

QvasiModo

Quote from: Robert Collins on January 10, 2005, 11:30:03 PM
Nope, doesn't help at all. I already know what it implies, what I want to know is why does EXIT <eax> cause a compile error. 

If you know what it implies, then why are you still using it wrong? :bg

You code:
OpenFileDlg 0, 0, addr CaptionText, addr szFilter

produces this:


invoke OpenFileDialog,0,0,reparg(addr CaptionText),reparg(addr szFilter)   ; good...
eax                                                                        ; what's this? ouch!

Robert Collins

 :red Well hit me upside my feeble brain. I see what you did now (duh).

When I said I know what it implies I meant I knew it returned a value I just didn't know how to use it like you indicated. I missed that in your first reply. My bad  :red

QvasiModo

Happened to me a lot, sometimes the most obvious answer is the hardest to see! :lol

Robert Collins