Page 1 of 1

Declare doesn't match with real Procedure

Posted: Thu Apr 20, 2023 2:31 pm
by stolzy
Very much on the toe of the learning curve here, but I hope somebody can help me here:
This code gives the 'Declare doesn't match with real Procedure' error

Code: Select all

XIncludeFile "//Users/stolzy/Documents/PureBasic/Forms Experimentation/temp/MyForm.pbf"

OpenJS_Window()

Procedure.s StringGadgetProcedure(EventType)
  TextInput.s = GetGadgetText(JS_String_Gadget)
  ProcedureReturn TextInput.s
EndProcedure

Repeat
  event=WaitWindowEvent()
  JS_Window_Events(event)
Until event=#PB_Event_CloseWindow

Debug TextInput.s
Can some kind soul help?

Re: Declare doesn't match with real Procedure

Posted: Thu Apr 20, 2023 2:37 pm
by mk-soft
Remove the procedure type '.s' and ProcedureReturn.

A event procedure have not a return type.

Re: Declare doesn't match with real Procedure

Posted: Thu Apr 20, 2023 2:54 pm
by stolzy
mk-soft wrote: Thu Apr 20, 2023 2:37 pm Remove the procedure type '.s' and ProcedureReturn.

A event procedure have not a return type.
Thanks for helping out (and so quickly :-)

Does this mean I am obliged to declare TextInput.s as a global variable in order to get it out of the procedure?
Is there a better way?

Re: Declare doesn't match with real Procedure

Posted: Thu Apr 20, 2023 3:04 pm
by mk-soft
That is correct that this must be global for later use.
For this kind of data I would recommend you to use global structures to avoid having too many single global variables.

Remember that the gadgets support different event types and need to be filtered.
See the help for the different gadgets.

Update

Code: Select all


Structure sCommonData
  TextInput.s
  TextXYZ.s
  ; and more
EndStructure

Global CommonData.sCommonData

Procedure StringGadgetProcedure(EventType)
  Select EventType
    Case #PB_EventType_Change
      CommonData\TextInput = GetGadgetText(JS_String_Gadget)
    Case #PB_EventType_Focus
      ;
    Case #PB_EventType_LostFocus
      ;
  EndSelect
EndProcedure

Re: Declare doesn't match with real Procedure

Posted: Thu Apr 20, 2023 5:33 pm
by stolzy
Your assitance is much appreciated.