Accessing Data and Objects
Not only can you access local variables in FPScript, but you can also access external data sets and calculation results. If you use a name such as "DataSeries", FPScript proceeds as follows to find the object with this name. Initially, FPScript checks to see whether a pre-defined constant exists with this name. It then checks to see whether a local variable has been defined with this name in the formula. If neither is the case, and if the FPScript formula is a function with arguments, it checks to see if an argument variable exists with this name. If nothing is found during the search, it searches for a data set or a formula with this particular name. The search takes place in the folder containing the formula. If, however, this folder has an activated subfolder, this subfolder takes priority in the search. If the object found is a formula, this is calculated, if necessary, and the result is taken for further calculation.
Path Name
The object path name describes its precise location within the project database.
Absolute path names provide the path from the root folder of the project database to the required object. Folder names are listed as a series, where each folder name ends with a '\'. Since the root folder does not have a name, only a '\' is written for it. Therefore, all absolute path names start with a '\'. The following example locates the object called "DataSet" in the "Measurement1" subfolder of the "Analysis" folder:
\Analysis\Measurement1\DataSet
The "Measurement1" subfolder is selected this way:
\Analysis\Measurement1
This access provides all data sets within the folder as a list in the order in which they are displayed in the unsorted object list.
Note: If in the example above a data set called "Measurement1" is in the "Analysis" folder, access will be provided to this data set and not to the folder of the same name. To access the folder in this case as well, you need to add the '.fld' extension.
An object called "DataSet" located in the root folder is selected as follows:
\DataSet
If there are special characters, e.g., spaces, in the path name, or if it begins with a number, then you must specify the path using single quotation marks:
'\Analysis\Measurement A\DataSet'
'\01\DataSet'
If objects are to be accessed that are not data sets, formulas, analysis objects or folders, you have to specify a file name extension :
\Analysis\Document.doc
You can access the activated subfolder of a folder using the ActivatedFolder keyword, which does not have a '\' at the end:
\Analysis\ActivatedFolder
Relative path names provide the path to the target object from the folder from which you are trying to access it. Here, '.\' describes the folder from which you are trying to access it, and '..\' describes the parent folder, which is the folder above it in the folder hierarchy. The following example is accessing a data set located in the neighboring folder called "Measurement2":
..\Measurement2\DataSet
This reads the folder name from which access is occurring:
.\.Name
You can access a data set located in the "Measurement1" subfolder as follows:
Measurement1\DataSet
To access an object located in the same folder, you only need to provide its name:
DataSet
or
Worksheet.wks
Relative path names never start with a '\', but instead either start with '.\' or '..\' or with the name of the subfolder.
To make it easier to create a list of objects, you can use the placeholders '*' and '?' in path names:
'\Measurement*\Signal' corresponds to [\Measurement1\Signal, \Measurement2\Signal, ...].
Use the placeholder '*' for a string of any length and the placeholder '?' for a single character.
Note: If you use an absolute path name or a relative path name that starts with '.\', then any activated subfolder will be ignored, which means that the path name always describes the specified object exactly, even if there is interference by an object with the same name in the activated subfolder.
Indirect Access
The Indirection Operator ($$) gives you the option of accessing objects using a string with the object name. The following example shows a common use:
Name = InputText("Please enter the name of the data set")
Integral($Name$)
Object Reference
An object reference is a reference to an object in FlexPro, e.g. to a formula or folder. You can use this type of object reference to access the value of the object reference or to access the properties of the object, e.g. access its name or comments. If you use the path name to a data object in FPScript, it will represent the data object value and will not provide an object reference. To construct it, you need to use the Set statement or the As Object keyword:
Dim Obj = DataSet As Object
or
Set Obj = DataSet
However, the Indirection Operator ($$) also provides an object reference for data objects:
Dim Obj = $"DataSet"$
is equivalent to:
Dim Obj = DataSet As Object
If a path name does not refer to a data object but instead refers to a folder, for instance, then in this case the folder represents the object reference. The following statements are therefore equivalent:
Dim Obj = Folder.fld As Object
or
Dim Obj = Folder.fld
FlexPro analyzes an object reference automatically if the value is required for additional calculations. You can use the Value Operator to analyze an object reference explicitly:
Dim Val = Value $"DataSet"$