Promotic
WikipediaLinkedInYoutubeTwitterFacebook

Opening the viewer for folder/file selection (/#glob/filepath)

The window for selecting the folder/file is opened by the Pm.CreateView method. In the parameter sViewPath the global path "/#glob/filepath" is entered.

This viewer is not functional in Web panels.

Viewer parameters:
initValue[optional] (String) Initial selection of file/folder, preferably as PROMOTIC path to files and folders.
mode[optional] (Long) (Long) Selection mode defines whether the result is a path to file or to folder.
1 (default) - File selection.
2 - Folder selection.
roots[optional] (PmMap) A list of selection origins (root) (logic folders, physical discs, ...) in the form of embedded map (Submap). In order to easily create/set an embedded map (Submap) in another map's item it is possible to use the PmMap.mapSetSubmapAt method. This method creation of the submap in the item and can add multiple item from a string in the KeyVal syntax.

Each selection origin (root) is constituted by a pair of values: description (titleN) and value (valueN), where N is the index (from 0). The titles (titleN) are optional. For example in the original KeyVal notation before transfering into the PmMap object, the entry could look like this: "title0:Boiler1;value0:#data:Boiler1/;title1:Boiler2;value1:#data:Boiler2/;" If not set, then there will be only a single selection origin defined by initValue. The allowed values (valueN) of selection origins (root) are:

#xx - Origins of PROMOTIC paths, e.g. "value0:#pmres;value1:#appres;"
#xx:yy/zz - PROMOTIC paths including the subfolders, e.g. "value0:#pmres:Img/;value1:#appres:Img/;"
disk: - Devices as drive letters, e.g. "value0:c:;value1:d:;"
disk:yy/zz - Paths as drive letters including subfolders, e.g. "value0:c:\Temp\;value0:d:\Data\;"
$disks - All mapped physical drive devices (drive letters) are added automatically, e.g. "value0:$disks;"
hide[optional] (Long) Allows to define what is to be hidden.
0 (default) - Show all.
1 - Hide subfolders.
2 - Hide files.
existence[optional] (Long) Allows to set whether the selected file/folder (non)existence is tested.
0 (default) - Not tested.
1 - Confirm if the selected file/folder exists.
10 - The selected file/folder must exist.
11 - The selected file/folder must not exist.
defaultExt[optional] (String) Default new file extension if if not defined otherwise. For example "csv".
filter[optional] (PmMap) A list of displayed file filters in the form of embedded map (Submap). In order to easily create/set an embedded map (Submap) in another map's item it is possible to use the PmMap.mapSetSubmapAt method. This method creation of the submap in the item and can add multiple item from a string in the KeyVal syntax.

Each filter is constituted by a pair of values: description (titleN) and value (valueN), where N is the index (from 0). The titles (titleN) are optional. For example in the original KeyVal notation before transfering into the PmMap object, the entry could look like this: "title0:Pictures;value0:*.jpg,*.png,*.bmp;title1:All files;value1:*.*;" If not set, then there will only be a single filter in the selection for all files.

title[optional] (String) Window header, if the window is displayed including header (for target:_blank;)
onChange[optional] (Function) The event function for managing the event of viewer modification.

For JavaScript the object function is entered.

For VBScript the object PmAction is entered.

The function has a single parameter ev containing information regarding the corresponding event.

ev.value - (String) Currently selected path to file/folder.
onClose[optional] (Function) The event function for managing the event of viewer closing.

For JavaScript the object function is entered.

For VBScript the object PmAction is entered.

The function has a single parameter ev containing information regarding the corresponding event.

ev.CloseReason - (String) Identifier of the window closing type. The value "ok" represents a valid selection. The values "cancel" or "" represent cancelled selection.
ev.ReturnValue - (String) Resulting selected file/folder.
The viewer parameters are in the form of the PmMap object that is filled from value of the sView parameter (of the KeyVal type) in the Pm.CreateView method.

By filling from the KeyVal value all the parameters are initially stored as string. The content of the PmMap object can be then modified as needed - the items can be modified, added and deleted.

The PmMap object can also contain other embedded PmMap objects (Submap). The PmMap.mapSetSubmapAt method can be used in order to create a new PmMap or make one accessible.

Example1:
Selection of file that is located only in the folder of the application (only ini, log or all files)
JavaScriptSelect and copy to clipboard

var oCreator = Pm.CreateView(pMe.PmPanel, "/#glob/filepath", "title:App files;initValue:#app:MyApp.log;mode:1;hide:1;defaultExt:ini;", "target:_blank;modal:1;");
var oView = oCreator.View;
oView.mapSetSubmapAt("filter", "", "title0:Setting log;value0:*.ini,*.log;title1:All files;value1:*.*;");
oView.onClose = function(ev) { Pm.Debug("onClose ReturnValue=" + ev.ReturnValue); };
oCreator.Open();
Example2:
Selection of path to folder located in this application (#app:). The returned value is then processed in the function onClose.
JavaScriptSelect and copy to clipboard

function onClose(ev)
{
if (ev.CloseReason == "ok")
Pm.Debug("onClose ReturnValue=" + ev.ReturnValue);
}

var oCreator = Pm.CreateView(pMe.PmPanel, "/#glob/filepath", "title:PmAppFiles,initValue:#app:;mode:2;", "target:_blank;modal:1;");
oCreator.View.onClose = onClose;
oCreator.Open();
Example3:
Saving the string into a new or selected txt file in the Data (#data:) folder. The returned value is then processed in function onClose.

While processing, it is supposed that there is a SaveFile method present in the panel, that receives the parameters and use the FileTextWrite method to save the file and sends back the saving result

JavaScriptSelect and copy to clipboard

function onClose(ev)
{
if (ev.CloseReason == "ok")
{
var sFilePath = ev.ReturnValue;
if (sFilePath != "")
{
var sText = "Hello world!";
var bDone = pMe.PmPanel.Methods.SaveFile(sFilePath, sText);
Pm.Debug("Save text fo file = " + sFilePath " is " + bDone);
}
}
}

var oCreator = Pm.CreateView(pMe.PmPanel, "/#glob/filepath", "title:Create File;initValue:#data:;mode:1;defaultExt:txt;", "target:_blank;modal:1;");
oCreator.View.onClose = onClose;
oCreator.Open();

History:
Pm9.00.09: Created
PROMOTIC 9.0.9 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