Object PmForm (Form)

Object represents a form used for data entry.
Properties and methods:
CreateItem Creates a single list item
GetItem Returns Pmf object (i.e. existing form item)
Title Displayed form name in the window title bar
BgColor Form window background color
SysButtons System buttons selection
Close Close form viewer
List of Pmf subobjects:
PmfString Text input
PmfNumber Integer or real number input
PmfBool Boolean value input item (Checkbox)
PmfEnum Selection of one of multiple items (Combobox)
PmfButton Button
PmfLayout Area for other Pmf objects
PmfSepar Separator between configurators
PmfTable Table
PmfObject Formal object - parent of all form items
- The object can be created by the method Pm.CreatePmForm.
- This object is functional also for Web panels.
- The object can be used in both VBScript and JavaScript languages.
The PmForm object can be used to create a data input window (form) dynamicaly (i.e. by script). Each "input value" represents one Pmf object, alias one item of the form.

The form can also be created by the PmaPanel object, but the PmForm object allows to create such form dynamicaly and more simply, because the form items are positioned and resized automatically as needed.

In the PmaPanel object it is also possible to use the PmForm object by means of the PmgForm graphic object.

Main areas for placing the Pmf objects:

The PmForm object automatically creates several system objects of the PmfLayout type.

All these objects have an identifier beginning with the $ character.

$main: Main area that is default for creating all Pmf objects by the PmForm.CreateItem method. This PmfLayout is set to have "Subtype:vert" so all objects created in it will be placed vertically (i.e. one uder the other).
$sys: System area (default: to the right from the $main area) that is used in two scenarios:
- If the PmForm object is opened in modal window and if the Pm.CreatePmForm method has "UseSysLayout:auto;" then the system buttons are added here automaticall based on the settings of the PmForm.SysButtons property.
- If the Pm.CreatePmForm method has "UseSysLayout:yes;", then the application designer is allowed to insert Pmf objects into this area.
Form creation procedure:
Creates a modal window for data input of values
1. In a single script (e.g. by button press in the onButtonUp event) a form is created, set and open:
JavaScriptSelect and copy to clipboard

//Creates a form object
var oTable, oTabFHead, oTabArea, oTabHead, oHeadRow, oTabLeftBody, oTabFLeft, oTabFooter, oFootRow, nRows, nCols, oRow, i, j, oItem;
var oForm = Pm.CreatePmForm();
oForm.Title = "Package storage parameter input box";

//Creates form entries:
oItem = oForm.CreateItem("number", "n1", "Number of packages", "Min:0;Max:33;");
oItem.Value = 5;
oItem = oForm.CreateItem("bool", "b1", "Store");
oItem.Value = true;
oItem = oForm.CreateItem("string", "s1", "Description");
oItem.Value = "Packed water";
oItem = oForm.CreateItem("enum", "e1", "Processing speed");
oItem.AddRow(0.5, "slow");
oItem.AddRow(9.9, "fast");
oItem.Value = 0.5;

oTable = oForm.CreateItem("table", "t1", "Table");
oTable.InitRows(5, 2, 1);  //nBodyRow, [nHeadRow, nFootRow]
oTable.InitCols(6, 1);  //nBodyCol, [nLeftCol]
oTable.EditType = "auto";

//Table LeftHead
oTabFHead = oTable.GetArea(22);
oTabFHead.GetRow(0).GetCell(0).Value = "Table Promotic";
oTabFHead.BgColor = "#ffffca";

//TableArea (Rows, Cols, BgColor)
oTabArea = oTable.GetArea(11);
nRows = oTabArea.RowCount;
nCols = oTabArea.ColCount;
oTabArea.BgColor = "#ffffff";

//Table Head (BgColor, Column titles)
oTabHead = oTable.GetArea(12);
oTabHead.BgColor = "#d0d0d0";
oHeadRow = oTabHead.GetRow(0);
for (i = 0; i < nCols; i += 1)
oHeadRow.GetCell(i).Value = "Col" + i;

//TableArea Values, LeftBody (Color, Rows titles)
oTabLeftBody = oTable.GetArea(21);
oTabLeftBody.BgColor = "#d0d0f0";
for (i = 0; i < nRows; i += 1)
oTabLeftBody.GetRow(i).GetCell(0).Value = "Row" + i;
oRow = oTabArea.GetRow(i);
for (j = 0; j < nCols; j += 1)
oRow.GetCell(j).Value = "r" + i + "c" + j;

//TableFooterLeft (Value, BgColor)
oTabFLeft = oTable.GetArea(23);
oTabFLeft.GetRow(0).GetCell(0).Value = "Result";
oTabFLeft.BgColor = "#caffff";

//TableFooter Values
oTabFooter = oTable.GetArea(13);
oFootRow = oTabFooter.GetRow(0);
for (i = 0; i < nCols; i += 1)
oFootRow.GetCell(i).Value = "Total" + i;

//Table Column width
oTable.SetColWidth("50px", 1, 0, nCols);

//Table Set active row
oTable.SetSel(0, 2);
//----- End Setting PmfTable ------

oItem = oForm.CreateItem("button", "reset", "Zero in");

//Opens form in modal window:
var oExtra = Pm.CreatePmMap();
oExtra.ViewObject = oForm;
oExtra.onChange = Pm.CreatePmAction(1, pMe, "FormChanged");
oExtra.onClose = Pm.CreatePmAction(1, pMe, "FormClosed");
pMe.PmPanel.OpenView("/#glob/form", "target:_blank;modal:1;", "", oExtra);
2. When entering values into the form the designer's method "FormChanged" is called each time any modification is done in the form (see oExtra.onChange). This way it is possible, for example, to detect that the "Zero in" button was pressed and all entries can be zeroed.

This designer's method is created on the "Methods" page and must have two parameters: oSystem and oPrivate.

JavaScriptSelect and copy to clipboard

if (oSystem.ChangeType == "push" && oSystem.ItemId == "reset")
var oForm = oSystem.ViewObject;
oForm.GetItem("n1").Value = 0;
oForm.GetItem("b1").Value = false;
oForm.GetItem("s1").Value = "";
oForm.GetItem("e1").Value = 0.5;
3. After the data entry is completed and the window closed the designer's method "FormClosed" is called. All entered values cen be detected here.

This designer's method is created on the "Methods" page and must have two parameters: oSystem and oPrivate.

JavaScriptSelect and copy to clipboard

if (oSystem.CloseReason == "ok")
var oForm = oSystem.ViewObject;
var val1 = oForm.GetItem("n1").Value;
var val2 = oForm.GetItem("b1").Value;
var val3 = oForm.GetItem("s1").Value;
var val4 = oForm.GetItem("e1").Value;

Pm9.00.04: New subobject PmfTable that can be used to assign a table of values into the form.
Pm8.03.17: Fixed bug: System buttons had only English texts.
- In each PmfObject object there are new properties TitlePos, BodyWidthMode, BodyWidthIni, BodyHeightMode, BodyHeightIni.

These properties can be used for better positioning of configurators.

- In the PmfString object there are new properties Multiline and Subtype. It is now possible to create multi-row input box, static notes, etc.
- In the PmfSepar object there is a new property Subtype. It is now possible to insert empty rows between the configurators.
- New form item type - separator, i.e. PmfSepar object.
- Close new method and new properties BgColor, SysButtons.
Pm8.03.08: allows creation of forms for data entry. Opens by the OpenView type method i.e. it can be open in an independent window, in the PmgFrame object, or in PmaWorkspace. It is functional also in Web panels. Replaces the obsolete method Pm.InputBox.
PROMOTIC 9.0.4 SCADA system documentation - MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice