XPAC Reference Guide

Using parameters in the main database

Using parameters in the main database

Previous topic Next topic  

Using parameters in the main database

Previous topic Next topic  

Once the parameters have been placed in a Parameters database, you will need to be able to access them from the Main Database. This is done using an XCM that is run over the Main database. An overview of the structure of such an XCM is described below. Click here to view example XCMs.

Parameters database record number

The first information that needs to be determined in the XCM is the relevant Parameters database record number, from which to read the parameters. This is done using the function GetRecFromPilDB. The input information for this function includes the database name (in this case the Parameters database) and the position in level (pil) number for each level in the Parameters database (starting with level 1). The Parameters database pil numbers are typically sourced from one of the following:

If the level in the Parameters database corresponds to a level in the Main database, then the pil number for that level can be read from the current Main database record. This can be done using GetApil(Level Number) or you can use the automatic XCM variables named lLevelNameNum where LevelName is the name of the relevant Main database level.
If the level in the Parameters database represents a Classification, then the value for the current Main database record must be determined. This may be read from a classified data field in the Main database, using the function GetClass(Data Field Code), or it may be assigned to a user-defined variable using some XCM logic. A simple example is, if the strip number is greater than 12 then the record is in Class X, otherwise the record is in Class Y. This process may assign the Classification as a number or a string. If it is a number that corresponds to a pil number in the Parameters database level, then it can be used in the GetRecFromPilDB function. If it is a string that corresponds to a record name in the Parameters database level, then you will need to find the corresponding pil number. This can be done using the function GetPilFromPositionName, as long as the Parameters database level has a position table defined.

Parameters database data field number

The next information that is needed in the XCM is the number of the Parameters database data field which contains the parameter that is to be read. Since the XCM is being run over the Main database and not the Parameters database, the Parameters database data field codes will not be automatically recognised. Consequently, the function GetRowNumFromCode must be used to get the data field number, given the database name and the full row code.

Read parameters database

Once you have the Parameters database record number and data field number, they can be used in the DbReadValue function to read the parameter from the Parameters database. The parameter can then be stored in a user defined variable, or written into the Main database, and used in further calculations.