This script show a simple and preliminary Form Generator for PowerShell, developed with 3.0 version.
Using the program
The script contains a function
which needs a fields description in order to start and other non mandatory parameters:
widgets a mandatory string containing the fields description;
title a possibly string which is the title in the form;
caption a possibly string which is the caption form.
$parm = "Psw,psw,txt password;cmb,combo,,,g,a:alfa|beta|g:gamma|delta;list,combo2,,25,,a:aleph|bet|g:gimel|dalet"
$parm += ";Chk,check,Check box,,"
.\formgenbase.ps1 -widgets $parm -title "Try Form Generator"
Every widget description is characterized by a list of attributes (comma separated) in this order:
Type, Field Name, Field Label, Length, Default Value and Extra. Every description is separated by semicolon:
Type is the widget type, they are for now, five types: text, password, list, combo box and check box.
Name the widget name.
Label the widget label.
Length the widget length.
Default the possible default value.
Extra an extra field for add information to the widget, (this depends on the type).
The program inserts three buttons:
, but if there is only one list
widget, no buttons are presents because the choice on item exits the form.
Closing the form, the global variable
$fg_data, an hash table where the key is the widget name,
contains the input inserted plus a key
fg_button whit the name of the button clicked.
There are no particular things to tell for widget type Text, password or check box. The data for the items of Lists and Combos are contained in the
each separated by the character |; every item can have a possible key, which is returned if the item is selected; the syntax is:
key:value; if one would propose an item by default, the key or the value must be inserted in the default field.
the cancel button was pressed or the form is closed in the menu bar, there is only
Use $host to determine the PowerShell engine version.
Maybe in the future
First the software needs of an event handler for personalize the widgets or to add controls. Also may add some controls like mandatory fields, mail check etc.
The script lacks of important widgets like slider, numeric fields, radio button, file dialogue, date and time...