Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

One of the important features of the Oasis processing environment is the strategy employed for storing and retrieving various settings, such as channel names and processing parameters that are used in your GXs. When designing applications, you need to be aware of how Oasis manages such parameter storage and retrieval operations. Data can be stored in a number of different places, depending on its context and purpose. Proceeding from most general to most specific, information can be stored in the geosettings META file, in an individual project, or in a database line or channel. Information can also be saved to a map, or an individual view within the map. Choice of location is dependent on how widely the user wishes the information to be made available, and how specific it is to the object with which it is stored. 

Table of Contents


 

Parameter Storage in the geosettings META file

The geosettings META file in the Geosoft ini directory contains global default settings for use throughout the Oasis montaj environment. This is the type of parameter set using the “Oasis montajSettings” menu item (the SETTINGS GX) or the Advanced Settings (the ADVSETTINGS GX). To set a parameter in the geosettings META file, examine the following example:

Code Block
GlobalSet_SYS("MYGROUP.MYPARAM", “Example”"œExample");

This command sets the system parameter “MYPARAM” in the group “[MYGROUP]” to the value “Example”. Once all values are set, it is necessary to use the following command to save the changes to the actual file:

Code Block
WriteGlobal_SYS("");
Stored values may be retrieved in the following manner:
 
if (iGlobal_SYS("MYGROUP.MYPARAM",sTemp) == 0) {
            // Do something...
}

For more information on storing and retrieving global parameters, see the SYS.GXH header file.

Parameter Storage in the Project

Using SetInfoSYS_DGW and GetInfoSYS_DGW

The SetInfoSYS_DGW or GetInfoSYS_DGW functions transfer values between the workspace parameter block and the dialog. Without these functions, the transfer would require two steps. The following two lines:

Code Block
GetString_SYS(“MYGX”"œMYGX", “PARAM”"œPARAM", sBuff);    // --- retrieve from parameter block
SetInfo_DGW(Diag, _MYFORM_0, DGW_TEXT, sBuff);  // --- set in dialog

are replaced by...

Code Block
SetInfoSYS_DGW(Diag, _MYFORM_0, DGW_TEXT, “MYGX”"œMYGX", “PARAM”"œPARAM");

Perusal of GX code reveals that SetInfoSYS_DGW (and by extension GetInfoSYS_DGW), is used mainly for passing four different types of information: real, integer and string variables, read-only text, file paths, and list values.

Real, int and string variables

Read-only text

The “DGW_FILEPATH” argument is used when working with file names. Even though just the local name of the file is displayed in the dialog field, the full path, including disk and directories, is passed back and forth. The source code could be:

Code Block
SetInfoSYS_DGW(Diag, _MYFORM_0, DGW_FILEPATH, “MYGX”"œMYGX", “FILENAME”"œFILENAME");

The resource lines could be either of the following:

Code Block
FEDIT,,,40,"Create a New File",R,NEW,,,*.dat
FEDIT,,,40,"Open an Old File",R,OLD,,,*.dat

List values

Individual values from lists of items are passed as text strings, exactly as in the “Real, Int and String Variables” section above. Therefore the “DGW_TEXT” parameter is used:

Code Block
SetInfoSYS_DGW(Diag, _MYFORM_0, DGW_TEXT, “MYGX”"œMYGX", “SIZES”"œSIZES");

The corresponding lines in the resource file, along with the list items, could be:

Code Block
LEDIT,,,20,"Sizes",R,FORCE,"Large",SIZE
 
RESOURCE,LIST,SIZE
ITEM, Small
ITEM, Medium
ITEM, Large

List alias values

A special object, call the “REG” is used to store data within an individual database line, database channel, map or map view. An example is measurement units (such as “m” for meters), which are unique to a particular channel and which are stored within the channel REG. The following example illustrates how the channel REG is obtained and how parameter information is exchanged with it:

Code Block
// --- Create (an empty) REG object ---
ChReg = Create_REG(128);

// --- Get the channel symbol, and the channel parameter data ---
Ch = FindSymb_DB(Data,sCh,DB_SYMB_CHAN);
GetRegSymb_DB(Data, Ch, ChReg);

// --- Get values from the REG ---                
GetInt_REG(ChReg,"INTPARAM", iVal);
GetReal_REG(ChReg,"REALPARAM", rVal);
Get_REG(ChReg, "STRINGPARAM", sVal, sizeof(sVal));

// --- Use values...
.
.
.

// --- Set values back into the REG ---
SetInt_REG(ChReg,"INTPARAM", iVal);
SetReal_REG(ChReg,"REALPARAM", rVal);
Set_REG(ChReg, "STRINGPARAM", sVal);

// --- Set the REG data back into the channel ---
SetRegSymb_DB(Data, Ch, ChReg);

// --- Destroy the REG object ---
Destroy_REG(ChReg);

Note that the REG object is created, then filled with values from the channel using the GetRegSymb_DB function. If the REG object is altered, the new settings must be loaded back into the channel using SetRegSymb_DB for the changes to take effect in the channel itself. Finally, the REG must be destroyed.

The line REG is accessed in the same way as the channel REG. A new REG object is created, then filled, and must be destroyed in the end. It is accessed by using a line symbol:

Code Block
GetRegSymb_DB(Data, Line, LineReg); // Get REG from a line symbol
SetRegSymb_DB(Data, Line, LineReg); // Set REG to a line symbol

Access to other objects’ REGs is handled differently. For a MAP or MVIEW object, a handle to the object’s own REG is returned to the user, and the user works directly with the object’s REG. No Create or Destroy is performed, and no “SetREG_MAP” (for example) function is required:

Code Block
// --- Get the handle to the map REG ---
MapReg = GetREG_MAP(Map);

// --- Set a value in the map REG ---
Set_REG(MapReg, "MAP.MAPPARAM", sVal);

The REG in a map’s view is accessed using the GetREG_MVIEW function.

Data string values obtained from a REG may be loaded to, and retrieved from a dialog using the SetInfo_DGW and GetInfo_DGW commands. (When using REG-derived data in dialogs, it is most practical to work with all data, including real and integer variables, as strings using the Get_REG and Set_REG functions.) Alternatively, the REG settings can be added to the workspace parameter block using the SetREG_SYS function, so that the SetInfoSYS_DGW function can be used, as in the following example:

Code Block
GetRegSymb_DB(Data, Ch, ChReg);
SetREG_SYS(ChReg);

// --- REG parameters are now available as SYS parameters ---
SetInfoSYS_DGW(Diag, _MYFORM_0, DGW_TEXT, “MAP”"œMAP", “MAPPARAM”"œMAPPARAM");
.
.
.

Note that the REG parameters should be stored in the form “GROUP.PARAM” so that both the group and parameter values are defined in the system parameter block when SetREG_SYS is called.