Promotic

Example: Creates PmForm window with items for entering data

In a single script (e.g. after pressing the button in the onButtonUp event) a form is created, set and open:
JavaScriptSelect and copy to clipboard

var oNmb1, oBool1, oEnum1, oStr1, oBtn1;

// Creates PmViewCreator - The object allows opening the various viewers
var oCreator = Pm.CreateView(null, "/#glob/form", "", "target:_blank;modal:1;pos:view," + pMe.ViewX + "," + pMe.ViewY + ";");
oCreator.View.onLoad = onFormLoad;

// Opens form in a modal window:
oCreator.Open();


function onFormLoad(ev)
{
// Creates a form object
var oForm = ev.Form;
oForm.Title = "Setting";
oForm.AddEvent("onClose", "formclose", onFormClose);

// Creates form items (Pmf objects)

// PmfNumber
oNmb1 = oForm.CreateItem("number", "nmb1", "Number of packages", "Min:0;Max:33;");
oNmb1.Value = 5;

// PmfBool
oBool1 = oForm.CreateItem("bool", "bool1", "Store");
oBool1.Value = true;

// PmfEnum
oEnum1 = oForm.CreateItem("enum", "enum1", "Processing speed");
oEnum1.AddRow(0.5, "slow");
oEnum1.AddRow(9.9, "fast");
oEnum1.Value = 0.5;
oEnum1.AddEvent("onEditAccept", "ChangeEnum", onEnum1Accept);
function onEnum1Accept(ev)
{
if (oEnum1.Value == 9.9)
{
oStr1.Value = "fast - Packed water";
}
}

// PmfString
oStr1 = oForm.CreateItem("string", "string1", "Description");
oStr1.Value = "Packed water";

// PmfButton
oBtn1 = oForm.CreateItem("button", "but1", "Zero in");
oBtn1.Value = "Reset";
oBtn1.AddEvent("onAction", "but1reset", onBut1Reset);
function onBut1Reset(ev)
{
if (ev.Action == "main")
{
oNmb1.Value = 5;
oBool1.Value = true;
oEnum1.Value = 0.5;
oStr1.Value = "Packed water";
}
}
}


function onFormClose(ev)
{
if (ev.CloseReason == "ok")
{
Pm.Debug("onClose: " + oNmb1.Value + ", " + oBool1.Value + ", " + oEnum1.Value);
}
}
PROMOTIC 9.0.27 SCADA system documentation MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r.o.