Multiple Forrm project

Archived support forum for customers who once purchased a PrimalForms product license. This forum is locked.
This topic is 12 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
bmclain
Posts: 39
Last visit: Fri Dec 03, 2021 7:36 am

Multiple Forrm project

Post by bmclain »

I've just now gotten started with using a project instead of just a file. I'm having issues figuring out the order of how it all flows together. My main issue right now is that I created a help form separate from my main form. I can't seem to perform the Call-Help_Dialog_pff to be defined before I call it. I try to call the form from the Globals.ps1 file, but it doesn't appear to be defined yet. At what point is this defined/how can I make sure that it's defined before I call it?Is there any doc to describe how primalforms will flow through the Startup.pfs, Globals.ps1, and the defined forms?
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Multiple Forrm project

Post by davidc »

The Startup's Main Function is considered the entry point.You should never call a form directly from Globals.ps1 unless it is in a function that is called by another form or the Main function. Only use the Globals.ps1 to define variables or functions. I don't recommend to using it to execute scripts directly. If you like a better idea what is happening behind the scenes I recommend exporting the project into a ps1. You will see the files are combined into a larger script. Essentially the contents of the Global.ps1 are appended to a larger script and if you try to call a form, it is possible that the form's function has not been defined until later in the script. David
David
SAPIEN Technologies, Inc.
User avatar
kghammonddc
Posts: 13
Last visit: Wed Aug 06, 2014 9:38 am

Multiple Forrm project

Post by kghammonddc »

I like this thread...

A few programming style questions.

1) We have been putting our functions in the mainform.pff. Could we place them in global.ps1 instead or is the scope different. I think it would be different. We totally missing startup.pfs. I assume functions / variables in startup.pfs will also be in a different scope that mainform.pff. Maybe that is better...

2) Is it possible to add parameters to the Main function for parameter passing from the command line, or do we have to manually parse them out of $Commandline or from $args?

Thank You,
Kevin
User avatar
bmclain
Posts: 39
Last visit: Fri Dec 03, 2021 7:36 am

Multiple Forrm project

Post by bmclain »

Parameters should be defined in the Startup.pfs at the top. their packager will look for it there and make sure it's at the top of the script when it's compiled.Functions in Startup get put in first, then functions in the global. The it appears that the commands in global get executed. I find it difficult to see this in primalforms since the functions I put in other scripts don't show up as callable in the other scripts. So, I've essentially been putting all functions in startup.pfs and any commands in the Main function. that way it knows about the functions. I then just make sure that if the variable is needed outside of the main function that I set it to a script variable.
User avatar
bmclain
Posts: 39
Last visit: Fri Dec 03, 2021 7:36 am

Multiple Forrm project

Post by bmclain »

Oh, and also you will find that the parameters are only valid if you export to a .ps1 file. If you need command line options you have to use the $commandline. Or if you have something that might be both (like mine), then you need to make sure to code for both.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Multiple Forrm project

Post by davidc »

1)
Yes
you can place the functions in the Global.ps1 file and they will be accessible
to any script in the project. The file is there for your convenience. 2) If you define a parameter block at beginning of the startup.pfs file, you will be prompted for the parameters when you run the script. If you are using a packaged exe and are passing parameters to the executable, then you will need to use either $args or $commandline. David
David
SAPIEN Technologies, Inc.
This topic is 12 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.