Page 1 of 1

Form code in PowerShell Studio 2014/2015

Posted: Fri Feb 06, 2015 6:15 am
by clum09
Hello,

I like to see PowerShell Studio can allow me to see the form code within the Editor.

This is because when I write the GUI application, I like to integrate a sub form within the main form so that the sub form is loaded before the main form loads.

I use the sub form as a splash screen before the main form loads.

Currently, I have to export the form code from PowerShell Studio and do my final editing within PrimalScript in order to combine the sub form into the main form which requires a lot of work.

I don't know the reason why the form code has to be encrypted within PowerShell Studio 2014/2015 to begin with. Pleas explain the reason why.

Thank you.

Form code in PowerShell Studio 2014/2015

Posted: Fri Feb 06, 2015 6:16 am
by SAPIEN Support Forums
This is an automated post. A real person will respond soon.

Thank you for posting, clum09.

Did you remember to include the following?
  • 1. Product, version and build (e.g. Product: PowerShell Studio 2014, Version & Build: 4.1.71. Version and build information can be found in the product's About box accessed by clicking the blue icon with the 'i' in the upper right hand corner of the ribbon.)
    2. Specify if you are running a 32 or 64 bit version
    3. Specify your operating system and if it is 32 or 64 bit.
    4. Attach a screenshot if your issue can be seen on the screen
    5. Attach a zip file if you have multiple files (crash reports, log entries, etc.) related to your issue.
If not, please take a moment to edit your original post or reply to this one.

*** Make sure you do not post any licensing information ***

Re: Form code in PowerShell Studio 2014/2015

Posted: Fri Feb 06, 2015 8:45 am
by davidc
You should never have to edit the generated code. You can accomplish this using a project or by placing your custom code in the script editor. Otherwise you are creating extra work for yourself everytime you change the GUI.

Please refer to the following articles:

http://www.sapien.com/blog/2014/08/05/p ... -controls/

http://www.sapien.com/blog/2013/10/01/p ... ing-forms/

The only way to see the code, is to export the GUI script in the Deploy tab.


David

Re: Form code in PowerShell Studio 2014/2015

Posted: Fri Feb 06, 2015 9:00 am
by clum09
David,

Why is form code within PowerShell Studio encrypted to begin with and at the same time why does PowerShell Studio allow the export of the form code?

Tell me how I can have two form codes in one single script file within PowerShell Studio 2014/2015 since the the code in PowerShell Studio is completely encrypted.

That is that point I am trying to make. I need to see the form code within PowerShell Studio so that I don't have to export the code from PowerShell Studio to PrimalScript to combine the two form codes (one sub form and one main form) and do my final touch of the code.

Will PowerShell Studio allow me to create two forms within one editor?

Re: Form code in PowerShell Studio 2014/2015

Posted: Fri Feb 06, 2015 9:45 am
by davidc
PowerShell Studio's form script is not encrypted. What you are referring to is the recovery block. This allows you to recover your form, if you ever lose the original psf file.

You can disable this option in Options->Designer->Export->Embed recovery data in exported scripts.

If you scroll down the script, you will see the form code.

If you want to use multiple forms, you should use a project.
Depending on what you are doing, you can place your splash screen code in a separate ps1 file (or form) and call that it from your GUI script. Please refer to the second article.

You don't have to do it this way, but I'm just trying to save you time from having to modify an exported script over and over again.

David

Re: Form code in PowerShell Studio 2014/2015

Posted: Fri Feb 06, 2015 8:29 pm
by clum09
David,

I followed your instruction to reveal the form code by checking or unchecking the 'Embed recovery data in exported script' in the Options -> Designer within PowerShell Studio 2014/2015, but I cannot see the form code in either the Script tab or the Designer tab.

Where can I see the form code within PowerShell Studio 2014/2015?

Re: Form code in PowerShell Studio 2014/2015

Posted: Sat Feb 07, 2015 2:48 pm
by davidc
You must first export the script to see the generated code. Once you export the file, you can open it in the editor of your choosing.

If you open it in PowerShell Studio, just hit 'No' when it asks to open the original file.

David

Re: Form code in PowerShell Studio 2014/2015

Posted: Mon Feb 09, 2015 11:16 am
by clum09
David,

What you said was to export the .psf file to a .ps1 file first.

Then re-open the this new .ps1 file within PowerShell Studio 2015 and answer the question "No" when it prompts me for the source file.

If I did that, I lost all my ability to edit the form within PowerShell Studio 2015 - I am working with the .ps1 file directly within PowerShell Studio 2015 instead.

Why did people want to go through such a hassle to create the form and export and then import it back to work with the .ps1 file?

I like to see PowerShell Studio be able to see the form code from the .psf file to start with - not the .ps1 file since loading the .ps1 will not have the ability to see the Designer tab in PowerShell Studio.

Having the ability to see the form code within the Designer tab allows me to add a sub form within the main form and the control the behavior of the forms right within PowerShell Studio instead of another script editor.

Currently whitin PowerShell Studio Desinger tab, the form code cannot be seen.

Re: Form code in PowerShell Studio 2014/2015

Posted: Mon Feb 09, 2015 2:01 pm
by davidc
My whole point is you should not to edit the exported script. You asked how to see the code and I provided you with the steps.

The GUI to script is a one-way process. Therefore you can't edit the generated code and import it back into the designer. This one of the many reasons we do not display the script. In addition, the generated code is has been tested and verified to work as is.

If you want to add custom code, such as call another form, you can add that code directly in the script editor or use a project to handle multiple GUIs. The script in the edit editor will be processed before the GUI form is displayed.

David