Calling a Procedure from a "Master" file

You need some new stunning features ? Tell us here.
Neil
Enthusiast
Enthusiast
Posts: 198
Joined: Wed Feb 29, 2012 8:04 am
Location: Melbourne, AUS

Calling a Procedure from a "Master" file

Post 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,
User avatar
TI-994A
Addict
Addict
Posts: 2740
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: Calling a Procedure from a "Master" file

Post 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. :D
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
Neil
Enthusiast
Enthusiast
Posts: 198
Joined: Wed Feb 29, 2012 8:04 am
Location: Melbourne, AUS

Re: Calling a Procedure from a "Master" file

Post 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. :D
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,
User avatar
TI-994A
Addict
Addict
Posts: 2740
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: Calling a Procedure from a "Master" file

Post 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.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
Neil
Enthusiast
Enthusiast
Posts: 198
Joined: Wed Feb 29, 2012 8:04 am
Location: Melbourne, AUS

Re: Calling a Procedure from a "Master" file

Post 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:

Image

But then it "Declares" the procedure:

Image

and I get the error "procedure is already declared".

Thanks,
User avatar
TI-994A
Addict
Addict
Posts: 2740
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: Calling a Procedure from a "Master" file

Post 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. :?
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
Lothar Schirm
User
User
Posts: 54
Joined: Mon Nov 26, 2012 4:57 pm

Re: Calling a Procedure from a "Master" file

Post 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.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Calling a Procedure from a "Master" file

Post by IdeasVacuum »

I think you are expecting too much of the form designer.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Neil
Enthusiast
Enthusiast
Posts: 198
Joined: Wed Feb 29, 2012 8:04 am
Location: Melbourne, AUS

Re: Calling a Procedure from a "Master" file

Post 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
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Re: Calling a Procedure from a "Master" file

Post by Polo »

IdeasVacuum wrote:I think you are expecting too much of the form designer.
Is that a bad thing? :wink:

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 :)
Post Reply