In BindGadgetEvnt() I appear to be unable to pass a Parameter to the Procedure.
I would like to do BindEventGadget(#PB_Any, @ProcedureName(VarName))
But doing that falls over. I show a code snippit of how I would like to do and follow it with the code that works.
Am I right in my conclusion that I cannot pass a variable in a BindGadgetEvent(), or have I made a mistake in my code?
Code: Select all
;WHAT I WOULD LIKE TO DO
DeclareModule ANewModule
Declare DoWindowProc()
....
.....
Declare.s ProcSettingOnOff(AESC.s)
EndDeclareModule ; ANewModule
;
Module ANewModule
Enumeration
#Btn1
#Btn2
#Btn3
....
....
EndEnumeration
;
Global.s AESC
.....
....
Procedure DoWindowProc()
...
If OpenWindow(.....)
....
....
BindGadgetEvent(#Btn1, @ProcSetting("A"))
BindGadgetEvent(#Btn2, @ProcSetting("E"))
....
;
EndIf ; OpenWidow()
;
Procedure.s ProcSettingOnOff(AESC.s)
If AESC = "A" Or AESC = "E"
....
Else
....
EndIf
;
EndProcedure ; ProcSetingOnOff()
;
EndProcedure ; DoWindowProc()
...
;
EndModule ; ANewModule
________________________________________________
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
________________________________________________
WHAT I HAVE TO DO TO GET IT TO WORK
DeclareModule ANewModule
Declare DoScreenProc()
....
Declare DoBtn1Action()
Declare DoBtn2Action()
Declare DoBtn3Action()
.....
Declare.s ProcSettingOnOff(AESC.s)
EndDeclareModule ; ANewModule
;
Module ANewModule
Enumeration
#Btn1
#Btn2
#Btn3
....
....
EndEnumeration
;
Global.s AESC
.....
;
Procedure DoScreenProc()
...
If OpenWindow(.....)
....
....
BindGadgetEvent(#Btn1, @DoBtn1Action())
BindGadgetEvent(#Btn2, @DoBtn2Action())
....
EndIf ; OpenWidow
;
Procedure DoBtn1Action()
AESC = "A"
ProcSettingOnOff(AESC)
EndProcedure
;
Procedure DoBtn2Action()
AESC = "E"
ProcSettingOnOff(AESC)
EndProcedure
;
Procedure.s ProcSettingOnOff(AESC.s)
If AESC = "A" Or AESC = "E"
....
Else
....
EndIf
;
EndProcedure ; ProcSettingOnOff()
;
EndProcedure ; DoScreenProc()
...
;
EndModule ; ANewModule