PSGUI – Debugggingg – HowTo

Hi together,

today i want to show you, how you can debug XAML GUIs created with PSGUI.
And to be honest – this is absolutely easy! You don´t think so? Take a look below.


First of all you should open the PSGUI-Manager

1.JPG

Here you can see some demo GUIs – just select one

2.JPG

Now click on Dialogs – Debug Dialog (or as you can see press CTRL+D)

3.JPG

Afterwards the ISE will be opened with 3 opened files:
Debug-File – contains the debugging statements
ps1-File       – contains your events for the GUI and its objects
psm1-File  –  contains your additional functions

4.JPG

The first one is a dynamically created debug-file to provide you with the 2 relevant statements. The Flag “OnlyCreateVariables” will just create the global variables for all named objects in the GUI.

The variables are named like this:
$Dialogname_NameOfTheObject

– for instance in this example:
$03_ShowDialogResult_bEnde

By using this statement you could code your code and work with the Intellisense.
5.JPG
The other command without this flag is for live debugging. Herefore you have to set the Breakpoint before loading the GUI. (press F9 in the ps1/psm1-File in the specific lines)

6.JPG

Afterwards execute the “debugging line” to load the GUI (for example with F8) and it will stop at your Breakpoints:

7.JPG

At this point you can also prove every command in the command-line below

8.JPG

or the variables with MouseOver on the variables in the code

9.jpg

Try also to go through your code – line by line – by pressing

  • F10 – which will execute the whole line of the actual scope
  • F11  – which will also jump into code of codelines of your actual code
  • Shift + F11 – which will jump out of the code in the actual scope to its parent

And thats it: 

  • Intellisense for better and misstyping-proof coding
  • setting breakpoints and watching variables 
  • testing commands and statements in the CLI
  • live debugging line per line with F10 / F11 / Shift+F11

A little remark here below – please keep in mind that you can debug only one window at a time with a opened ISE instance. Because of this you should open the PSGUI-Manager either with the Link or with Powershell.exe.

Happy debugging and thanks for the read!

Best regards,

David

Advertisement