Declare doesn't match with real Procedure

Just starting out? Need help? Post your questions and find answers here.
stolzy
New User
New User
Posts: 5
Joined: Sun Apr 16, 2023 7:47 am

Declare doesn't match with real Procedure

Post 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?
User avatar
mk-soft
Always Here
Always Here
Posts: 6209
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Declare doesn't match with real Procedure

Post by mk-soft »

Remove the procedure type '.s' and ProcedureReturn.

A event procedure have not a return type.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
stolzy
New User
New User
Posts: 5
Joined: Sun Apr 16, 2023 7:47 am

Re: Declare doesn't match with real Procedure

Post 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?
User avatar
mk-soft
Always Here
Always Here
Posts: 6209
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Declare doesn't match with real Procedure

Post 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
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
stolzy
New User
New User
Posts: 5
Joined: Sun Apr 16, 2023 7:47 am

Re: Declare doesn't match with real Procedure

Post by stolzy »

Your assitance is much appreciated.
Post Reply