Page 1 of 1
What variable type is "?" for CatchImage?
Posted: Sun Apr 07, 2024 12:59 am
by marcoagpinto
Heya,
I want to create a Procedure CatchImageEnhanced(gadget,?,error_message$).
What type of variable is the "?" ?
Code: Select all
; Pop-up menus
If CatchImage(#GLOBAL_IMAGE_POPUP_EDIT,?popup_edit)=#False : MessageRequester("Error", "Can't load image.",#PB_MessageRequester_Error) : EndIf
If CatchImage(#GLOBAL_IMAGE_POPUP_ADD,?popup_add)=#False : MessageRequester("Error", "Can't load image.",#PB_MessageRequester_Error) : EndIf
DataSection
; Pop-up menus
popup_edit:
IncludeBinary "./media/popup_edit.png"
popup_delete:
IncludeBinary "./media/popup_delete.png"
blah blah blah
Thanks!
Re: What variable type is "?" for CatchImage?
Posted: Sun Apr 07, 2024 1:07 am
by Kiffi
Re: What variable type is "?" for CatchImage?
Posted: Sun Apr 07, 2024 1:10 am
by marcoagpinto
Kiffi wrote: Sun Apr 07, 2024 1:07 am
Heya, is there a way to use it in the parameters of a Procedure?
Re: What variable type is "?" for CatchImage?
Posted: Sun Apr 07, 2024 6:01 am
by idle
something like this
Code: Select all
Procedure doit(param)
Protected len
len = PeekL(param)
Debug PeekS(param+4,len)
EndProcedure
DataSection
hello: ;set label
Data.l 5 ;set len of data to the image
Data.s "hello" ;set data
world:
Data.l 5
Data.s "world"
EndDataSection
doit(?hello)
doit(?world)
Re: What variable type is "?" for CatchImage?
Posted: Sun Apr 07, 2024 6:44 am
by marcoagpinto
Well, I give up, I tried and it didn't work.
Thanks for helping.
Code: Select all
CatchImageEnhanced(#GLOBAL_IMAGE_POPUP_EDIT,?popup_edit,"Can't load image.")
Procedure CatchImageEnhanced(MARCOAGPINTO_gadget,?MARCOAGPINTO_label,MARCOAGPINTO_error_message$)
If CatchImage(MARCOAGPINTO_gadget,?MARCOAGPINTO_label)=#False : MessageRequester("Error", MARCOAGPINTO_error_message$,#PB_MessageRequester_Error) : EndIf
EndProcedure
Re: What variable type is "?" for CatchImage?
Posted: Sun Apr 07, 2024 7:06 am
by STARGĂ…TE
The second argument in CatchImage() is just a memory address.
The ? operator is used to receive the memory address from a label: *Address = ? Label
Code: Select all
CatchImageEnhanced(#GLOBAL_IMAGE_POPUP_EDIT,?popup_edit,"Can't load image.")
Procedure CatchImageEnhanced(MARCOAGPINTO_gadget, *Buffer, MARCOAGPINTO_error_message$)
If CatchImage(MARCOAGPINTO_gadget, *Buffer)=#False : MessageRequester("Error", MARCOAGPINTO_error_message$,#PB_MessageRequester_Error) : EndIf
EndProcedure
Re: What variable type is "?" for CatchImage?
Posted: Mon Apr 08, 2024 11:51 pm
by netmaestro
It's a pointer, nothing more or less. Nothing to spend a lot of time analyzing.
Re: What variable type is "?" for CatchImage?
Posted: Tue Apr 09, 2024 4:34 am
by marcoagpinto
Okay, guys, thanks!
I no longer need to create the procedure since the catch image command should always work, so I created a procedure only for the error message:
Code: Select all
; Display a requester with an error message.
;
; To clean up the code
;
; V1.0 - 07/APR/2024
;
Procedure MessageRequesterError(MARCOAGPINTO_error_text$)
MessageRequester("Error",MARCOAGPINTO_error_text$,#PB_MessageRequester_Error)
EndProcedure
My basic idea is to have the code as simple and as small as possible.
Thanks!