Hi ! :)

Fasmw 14_4


.if condition
code
.elseif condition
code
.elseif condition
code
.else
code
.endif
OK no problem

But if..


.if condition
code
.if condition
code
.elseif condition ; <==== ERROR MESSAGE IF.INC
code
.else
code
.endif
.elseif condition
code
.elseif condition
code
.else
code
.endif

Friendly......Gges
Posted on 2003-01-13 08:06:32 by Asmgges
Sorry, but I wasn't able to reproduce that error. Please send the complete source.
Posted on 2003-01-13 08:23:31 by Tomasz Grysztar
Hi Tomasz :)



; Simple text editor - fasm example program

format PE GUI 4.0
entry start

include 'include\win32a.inc'
include 'include\macro\if.inc'

IDM_NEW = 101
IDM_EXIT = 102
IDM_ABOUT = 901

section '.data' data readable writeable

_class db 'MINIPAD32',0
_edit db 'EDIT',0

_title db 'MiniPad',0
_about_title db 'A propos de MiniPad',0
_about_text db "C'est un exemple Win32Asm cr?e avec Fasm.",0

hinstance dd ?
edithwnd dd ?
editfont dd ?

msg MSG
wc WNDCLASS
client RECT

section '.code' code readable executable

start:

invoke GetModuleHandle,0
mov [hinstance],eax
invoke LoadIcon,eax,17
mov [wc.hIcon],eax
invoke LoadCursor,0,IDC_ARROW
mov [wc.hCursor],eax
mov [wc.style],0
mov [wc.lpfnWndProc],WindowProc
mov [wc.cbClsExtra],0
mov [wc.cbWndExtra],0
mov eax,[hinstance]
mov [wc.hInstance],eax
mov [wc.hbrBackground],COLOR_WINDOW+1
mov [wc.lpszMenuName],0
mov [wc.lpszClassName],_class
invoke RegisterClass,wc

invoke LoadMenu,[hinstance],37
invoke CreateWindowEx,0,_class,_title,WS_VISIBLE+WS_OVERLAPPEDWINDOW,144,128,256,256,NULL,eax,[hinstance],NULL

msg_loop:
invoke GetMessage,msg,NULL,0,0
or eax,eax
jz end_loop
invoke TranslateMessage,msg
invoke DispatchMessage,msg

jmp msg_loop

end_loop:
invoke ExitProcess,[msg.wParam]

proc WindowProc, hwnd, wmsg, wparam, lparam
enter
push ebx esi edi
.if [wmsg],e,WM_CREATE
invoke GetClientRect,[hwnd],client
invoke CreateWindowEx,WS_EX_CLIENTEDGE,_edit,0,WS_VISIBLE+WS_CHILD+WS_HSCROLL+\
WS_VSCROLL+ES_AUTOHSCROLL+ES_AUTOVSCROLL+ES_MULTILINE,\
[client.left],[client.top],[client.right],[client.bottom],\
[hwnd],0,[hinstance],NULL
mov [edithwnd],eax
invoke CreateFont,16,0,0,0,0,FALSE,FALSE,FALSE,ANSI_CHARSET,OUT_RASTER_PRECIS,\
CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,FIXED_PITCH+FF_DONTCARE,NULL
mov [editfont],eax
invoke SendMessage,[edithwnd],WM_SETFONT,eax,FALSE
xor eax,eax
.elseif [wmsg],e,WM_SIZE
invoke GetClientRect,[hwnd],client
invoke MoveWindow,[edithwnd],[client.left],[client.top],[client.right],\
[client.bottom],TRUE
.elseif [wmsg],e,WM_SETFOCUS
invoke SetFocus,[edithwnd]
.elseif [wmsg],e,WM_COMMAND
mov eax,[wparam]
and eax,0FFFFh
.if eax,e,IDM_NEW
invoke SendMessage,[edithwnd],WM_SETTEXT,0,0
.elseif eax,e,IDM_ABOUT ; <================= ERROR
invoke MessageBox,[hwnd],_about_text,_about_title,MB_OK
.elseif eax,e,IDM_EXIT
jmp wmdestroy
.endif
.elseif [wmsg],e,WM_DESTROY

wmdestroy:
invoke DeleteObject,[editfont]
invoke PostQuitMessage,0
xor eax,eax
.else

defwndproc:
invoke DefWindowProc,[hwnd],[wmsg],[wparam],[lparam]
.endif

finish:
pop edi esi ebx
return

section '.idata' import data readable writeable

library kernel,'KERNEL32.DLL',\
user,'USER32.DLL',\
gdi,'GDI32.DLL'

import kernel,\
GetModuleHandle,'GetModuleHandleA',\
ExitProcess,'ExitProcess'

import user,\
RegisterClass,'RegisterClassA',\
CreateWindowEx,'CreateWindowExA',\
DefWindowProc,'DefWindowProcA',\
SetWindowLong,'SetWindowLongA',\
RedrawWindow,'RedrawWindow',\
GetMessage,'GetMessageA',\
TranslateMessage,'TranslateMessage',\
DispatchMessage,'DispatchMessageA',\
SendMessage,'SendMessageA',\
LoadCursor,'LoadCursorA',\
LoadIcon,'LoadIconA',\
LoadMenu,'LoadMenuA',\
GetClientRect,'GetClientRect',\
MoveWindow,'MoveWindow',\
SetFocus,'SetFocus',\
MessageBox,'MessageBoxA',\
PostQuitMessage,'PostQuitMessage'

import gdi,\
CreateFont,'CreateFontA',\
DeleteObject,'DeleteObject'

section '.rsrc' resource data readable

; resource directory

directory RT_MENU,menus,\
RT_ICON,icons,\
RT_GROUP_ICON,group_icons,\
RT_VERSION,versions

; resource subdirectories

resource menus,\
37,LANG_ENGLISH+SUBLANG_DEFAULT,main_menu

resource icons,\
1,LANG_NEUTRAL,icon_data

resource group_icons,\
17,LANG_NEUTRAL,main_icon

resource versions,\
1,LANG_NEUTRAL,version_info

menu main_menu
menuitem '&Fichier',0,MFR_POPUP
menuitem '&Nouveau',IDM_NEW,0
menuseparator
menuitem '&Quitter',IDM_EXIT,MFR_END
menuitem '&Aide',0,MFR_POPUP + MFR_END
menuitem 'A &propos...',IDM_ABOUT,MFR_END

icon main_icon,icon_data,'minipad.ico'

version version_info,VOS__WINDOWS32,VFT_APP,VFT2_UNKNOWN,LANG_ENGLISH+SUBLANG_DEFAULT,0,\
'FileDescription','MiniPad - example program',\
'LegalCopyright','No rights reserved.',\
'FileVersion','1.0',\
'ProductVersion','1.0',\
'OriginalFilename','MINIPAD.EXE'


But it works with an old version of if...


macro .if v1,c,v2
{
__IF equ
local ..endif
__ENDIF equ ..endif
local ..else
__ELSE equ ..else
cmp v1,v2
jn#c __ELSE
}
macro .else
{
jmp __ENDIF
__ELSE:
restore __IF
__IF equ ,
}
macro .elseif v1,c,v2
{
local ..else_new
jmp __ENDIF
__ELSE:
restore __ELSE
__ELSE equ ..else_new
cmp v1,v2
jn#c __ELSE
}
macro .endif
{
if __IF eq
__ELSE:
end if
__ENDIF:
restore __ELSE
restore __ENDIF
restore __IF
}

Friendly......Gges
Posted on 2003-01-13 08:44:48 by Asmgges


.if eax,e,IDM_NEW
invoke SendMessage,[edithwnd],WM_SETTEXT,0,0
.elseif eax,e,IDM_ABOUT ; <================= ERROR
invoke MessageBox,[hwnd],_about_text,_about_title,MB_OK
.elseif eax,e,IDM_EXIT
jmp wmdestroy
.endif
.elseif [wmsg],e,WM_DESTROY



When the first IF is true, eax gets modified by the SendMessage call... that could cause a failure of the next ELSEIF (because it compares with the changed eax now). Try to use another register or push/pop eax before/after that SendMessage call. Just a guess, I cant try it out now.
Posted on 2003-01-13 08:48:11 by bazik
Hi! Bazik :)
Thank you for the attempt
But the change of register does not make anything more
Problem has to be in the macro elseif.
Friendly....Gges
Posted on 2003-01-13 09:05:30 by Asmgges
Now I see...
The problem is in the ".elseif" macro, you should remove the last two lines from its definition. I'm updating it in the fasmw144.zip package, thanks for the report!
Posted on 2003-01-13 09:31:49 by Tomasz Grysztar
OK :alright:
Everything is well now
Thank you
Friendly.......Gges
Posted on 2003-01-13 09:40:06 by Asmgges