What variable type is "?" for CatchImage?

Just starting out? Need help? Post your questions and find answers here.
User avatar
marcoagpinto
Addict
Addict
Posts: 1076
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

What variable type is "?" for CatchImage?

Post 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!
User avatar
Kiffi
Addict
Addict
Posts: 1509
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: What variable type is "?" for CatchImage?

Post by Kiffi »

CatchImage() wrote:
Note: The "?" is a pointer to a label.
Hygge
User avatar
marcoagpinto
Addict
Addict
Posts: 1076
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

Re: What variable type is "?" for CatchImage?

Post by marcoagpinto »

Kiffi wrote: Sun Apr 07, 2024 1:07 am
CatchImage() wrote:
Note: The "?" is a pointer to a label.
Heya, is there a way to use it in the parameters of a Procedure?
User avatar
idle
Always Here
Always Here
Posts: 6031
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: What variable type is "?" for CatchImage?

Post 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) 
User avatar
marcoagpinto
Addict
Addict
Posts: 1076
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

Re: What variable type is "?" for CatchImage?

Post 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
User avatar
STARGÅTE
Addict
Addict
Posts: 2260
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: What variable type is "?" for CatchImage?

Post 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
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8452
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: What variable type is "?" for CatchImage?

Post by netmaestro »

It's a pointer, nothing more or less. Nothing to spend a lot of time analyzing.
BERESHEIT
User avatar
marcoagpinto
Addict
Addict
Posts: 1076
Joined: Sun Mar 10, 2013 3:01 pm
Location: Portugal
Contact:

Re: What variable type is "?" for CatchImage?

Post 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!
Post Reply