Primal Forms Primer II

So now that we have a form with a script, how do we know if it did anything?

I saw something called StatusBar in the tools menu, so I tried that. Turns out it is very simple to use.

Open up your form in PrimalForms and in the Designer tab, select the Toolbox. Way down towards the bottom, you will see “Statusbar”. Drag that over to your form. It will be named Statusbar1. Any time you want to update the Statusbar write $statusbar1.Text= “Some Text”, just as you would Write-Host in your script.

So in my example, I used this for my btnPing action.


$btnPing_Click={
[string]$target=$txtServerName.Text

$ping=Test-Connection -ComputerName $target

If ($ping) {
    $statusbar1.Text="Server Pings"
    }
Else {
        $statusbar1.Text="Server is Off Line"
    }
}

As Test-Connection returns as True or False, I just check the state of $ping and write out a message to the statusbar. I know, Test-Connection will give you a lot more data but that is a whole ‘nother conversation.

I also saw something called the DataGrid that might work. I just have not figured how to use it yet.

You can also rename the form and or the name that shows in the upper left hand corner. Click somewhere in a blank part of your form. The Properties list over on the right has an item called Appearance. In the box called Text, change the word Form to what you want to display up there. I chose “Ping Test”. Down in Design you will see that your form name is now formPingTest. This changes the name in your script as well.

Save your form and you are good to go.

Advertisements

2 thoughts on “Primal Forms Primer II

  1. I’m rather pleased to discover this web site. I need to express gratitude for your time invested creating this awesome article. I undeniably really liked every bit of it and I have you saved as a favorite read new info on your web site.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s