Pre form load execution, working to silent execution

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 6 years and 7 months 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
bgleason
Posts: 29
Last visit: Mon Oct 30, 2023 11:35 am
Been upvoted: 2 times

Pre form load execution, working to silent execution

Post by bgleason »

Product, version and build: PowerShell Studio 2017 v5.4.142
32 or 64 bit version of product: 64bit
Operating system:Win10
32 or 64 bit OS:64bit

*** Please add details and screenshots as needed below. ***
My Question is a two parter... I am exporting a psf as a ps1 script to process.
1. Where in the interface can I put code execution that is processed pre form loading so it is not a case of exporting the ps1 and making code modifications after the fact, if such a place exists...
2. End game is I would like a script/form to run silently unless an argument is passed to the script which will then force the form to load.

I have reviewed some information with regards to arguments passed to EXEs, same will apply for the .ps1 script, but just trying to see if there is a space in the interface that accounts for pre form execution/processng..

Thanks,

Brian
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Pre form load execution, working to silent execution

Post by davidc »

I recommend creating an Empty Project and add the psf file to the project.

In the Startup.pss file, add a switch parameter to the top of the file:

Code: Select all

param([switch]$ShowGUI)
and in the Main function of Startup.pss, check for the switch parameter:

Code: Select all

if ($ShowGUI)
{
	Show-MainForm_psf
}
else
{
	Run-NonGUIFunction
}
David
SAPIEN Technologies, Inc.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Pre form load execution, working to silent execution

Post by davidc »

If you plan to package the script into an executable, you will have to convert the switch parameter into a string or int value. For more details, please refer to the following article:

https://www.sapien.com/blog/2015/11/30/ ... able-file/
David
SAPIEN Technologies, Inc.
User avatar
bgleason
Posts: 29
Last visit: Mon Oct 30, 2023 11:35 am
Been upvoted: 2 times

Re: Pre form load execution, working to silent execution

Post by bgleason »

Ahhhhhh, I have always just been simple and either just started a new form or a new script... Starting a new project now opens me up a lil more.. Ugh, why did I never try that...

Thanks!!
User avatar
bgleason
Posts: 29
Last visit: Mon Oct 30, 2023 11:35 am
Been upvoted: 2 times

Re: Pre form load execution, working to silent execution

Post by bgleason »

Via the project, I am now leveraging Globals.ps1 and populating it with all my functions. I am trying to call one of those functions from my MainForm.psf and in that function, my objects that I use on that form are not available... Is there anything special I can do so those objects are available, textbox, labels, buttons and whatnot, or is my only option to pass them when I call the function.. Just seeing what my options are and trying to understand the scoping of the files of the project...

Thanks...
This topic is 6 years and 7 months 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.