How can I give my operators a way to browse and/or select files?

Do you need to give your operators the ability to access and choose a specific file from within any given folder? Or possibly have the ability to browse folders on a machine in a Windows Explorer interface, but only have the ability to see and choose a specific type of file, like a .doc or a .txt file or a file of a certain name but having varied extensions, while all other files within the folder remain hidden?

The RDFileN() function is used to open two different types of file browsers within an InduSoft Web Studio project. One file browser is used to select files only within a given folder, and the other browser allows the operator to browse the folder structure looking for a specific type of file that is specified while all others remain hidden. Wildcards (*) are allowed in order to see all files in the selected folder.

Developers would use this functionality to give Windows Explorer capability to the operator within a running project. When invoked, this function will display the list of files in a folder, or display the file structure and make it navigable.

Using RDFileN() can be a little confusing to invoke properly because of the number and format of the parameters to be configured, the browser types selected, and what file name format should be returned.

The usage format of the function is:

ReturnedValueTag = RDFileN(“tagSelectedFile“, strSearchPath, strMask, optNumChangeDir)

Where:

ReturnedValueTag

is any integer tag which is used to store the returned value of the function after it is run.

Legal returned values are:

0 – Success

1 – One of the parameters is not a string

2 – Parameter 1 contains an invalid tag name

3 – The user cancelled the operation

tagSelectedFile

is the name of the string tag receiving the name and path of a selected file.

The tag name must be enclosed in quotes, or the project will try to get the contents of the tag. Moreover, it must be a valid tag name — it cannot be a VBScript variable name, for example.

strSearchPath

is the file path (directory) to search.

strMask

is the mask used to filter the files.

optNumChangeDir

is the Optional numeric tag that indicates whether the operator will be able to change the browsing directory. If this parameter is omitted or set TRUE ( 1 ), then the window opened by this function will allow the operator to navigate to different directories. If it is set FALSE ( 0 ), then the window will be restricted to the directory specified by strSearchPath.

You can use tags in all the parameter fields.

The following screen shots show an application demonstrating the various capabilities of the RDFileN() function and how to use it. More assistance is available in the Help Manual for InduSoft Web Studio in Contents >> Appendix: Built-in Scripting Language >> File Functions >> RDFileN.

You can download this InduSoft demo application here to try it for yourself.

Richard Clark

InduSoft TMS