Page 1 of 1
Calling a Procedure from a "Master" file
Posted: Thu Feb 20, 2014 2:02 am
by Neil
Hi Polo,
I load a file with my common procedures:
Code: Select all
XIncludeFile "..\ProceduresCommon.pbi"
XIncludeFile "WindowMain.pbf"
XIncludeFile "Config.pbi"
XIncludeFile "Procedures.pbi"
If I set one of the form gadgets to call this procedure, Form Designer
Declares the Procedure and so I get an error.
Thanks,
Re: Calling a Procedure from a "Master" file
Posted: Thu Feb 20, 2014 5:09 am
by TI-994A
Neil wrote:...Form Designer Declares the Procedure and so I get an error.
Hi Neil. Just a stab in the dark here, but try including all the form designer files before the procedure files
(PBFs before PBIs):
Code: Select all
XIncludeFile "WindowMain.pbf"
XIncludeFile "..\ProceduresCommon.pbi"
XIncludeFile "Config.pbi"
XIncludeFile "Procedures.pbi"
Might avert the conflict.

Re: Calling a Procedure from a "Master" file
Posted: Thu Feb 20, 2014 5:18 am
by Neil
TI-994A wrote:Hi Neil. Just a stab in the dark here, but try including all the form designer files before the procedure files
(PBFs before PBIs):
Code: Select all
XIncludeFile "WindowMain.pbf"
XIncludeFile "..\ProceduresCommon.pbi"
XIncludeFile "Config.pbi"
XIncludeFile "Procedures.pbi"
Might avert the conflict.

Hi TI-994A,
Unfortunately not!! I did try that before posting.
I now get the error in the common file - i.e. the Procedure has already been declared.
Thanks,
Re: Calling a Procedure from a "Master" file
Posted: Thu Feb 20, 2014 5:45 am
by TI-994A
Neil wrote:...Procedure has already been declared.
It seems that it could be a duplicate declaration issue; are you declaring the procedures in your include files as well?
If so, try commenting them out, making sure that the procedures in the file are in proper hierarchical order, to maintain inter-procedural integrity, if any.
Re: Calling a Procedure from a "Master" file
Posted: Thu Feb 20, 2014 6:31 am
by Neil
TI-994A wrote:Neil wrote:...Procedure has already been declared.
It seems that it could be a duplicate declaration issue; are you declaring the procedures in your include files as well?
I am defining the Procedure in the "common" file.
The Form Designer "knows" the procedure exists as it lists it in the options:
But then it "Declares" the procedure:
and I get the error "procedure is already declared".
Thanks,
Re: Calling a Procedure from a "Master" file
Posted: Thu Feb 20, 2014 10:21 am
by TI-994A
Neil wrote:I am defining the Procedure in the "common" file.
The Form Designer "knows" the procedure exists as it lists it in the options...
...But then it "Declares" the procedure...
...and I get the error "procedure is already declared".
Thank you. The issue is clearly one of duplicate declaration. Since there doesn't seem to be any option in the form designer to suppress these automatic declarations of event procedures, and it is quite tricky to remove them manually, the only solution would be to excise the declarations from the procedures files. This would be a fairly simple process if there are no inter-procedural calls. However, if there were, you'd have to re-arrange the procedures to ensure that procedures being called precede the calling procedures.
Procedure declarations are purely optional to begin with, and their use in the form designer is meant to facilitate the inclusion of form and procedure files in any order.
I can't see any other solution.

Re: Calling a Procedure from a "Master" file
Posted: Fri Feb 28, 2014 7:51 pm
by Lothar Schirm
An other possibility would be not to generate and define event procedures in the form designer. In this case, the form designer generates only the "OpenWindow" procedure, you can write a short event loop in the main file:
Code: Select all
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
And you can use BindGadgetEvent() in order to connect a gadget event to a callback function (event procedure) in your main file.
Re: Calling a Procedure from a "Master" file
Posted: Sat Mar 01, 2014 12:38 am
by IdeasVacuum
I think you are expecting too much of the form designer.
Re: Calling a Procedure from a "Master" file
Posted: Sat Mar 01, 2014 8:06 am
by Neil
TI-994A wrote:The issue is clearly one of duplicate declaration. Since there doesn't seem to be any option in the form designer to suppress these automatic declarations of event procedures
Yes I know - I guess if it is possible, the best solution is for Form Designer to have a toggle to say if you want the Designer to declare Procedures.
Over to you Polo !!
Thanks
Re: Calling a Procedure from a "Master" file
Posted: Sat Mar 01, 2014 11:01 am
by Polo
IdeasVacuum wrote:I think you are expecting too much of the form designer.
Is that a bad thing?
I'm reading it all, I'm a bit busy at the moment but once I get some time I'll do a few updates
