Global variables are created by the Global Variables command. The command is called by one of the following means:
Icon |
Ribbon |
---|---|
Parameters > GUI Control > Global Variables |
|
Keyboard |
Textual Menu |
<SG> |
Parameters > Global Variables |
A global variable is a named value of one of the two types: text (string) or real. Global variables are accessible for editing in the variable editor or via the special functions across all currently open documents. The list of global variables and their values are saved automatically upon exiting the application (in the registry) and are restored upon launching the application.
The Global Variables command is used to set global variables and their values. As mentioned above, the list of global variables and their values is common for all documents used in one workstation of the T-FLEX CAD system. When the command is called, a window appears containing a list of existing global variables. The graphical buttons New, Edit, Delete allow you to make changes or add to the list of global variables.
To create a new global variable, click the corresponding button and specify the name, value and data type (real, text).
To change the set values for the selected variable, click the Edit button.
To delete a variable, select the corresponding line in the list and click the Delete button.
The created global variables will be stored until you delete them or until you update the system settings (global variables are stored in the system registry).
In any dialog where variables are allowed, or in the variable editor, you can get the value of a global variable by accessing it using the getg() or tgetg() function (for text values). You can set the values of global variables using the setg() and tsetg() functions. The syntax of the functions is described in the Functions for Working with Variables section.
If the drawing, in which the global variable was created using one of the setg() or tsetg() functions, is opened on another computer, then the same global variable will be automatically created at the new workstation.
It should be noted that global variables can be used, for example, to automatically generate documentation for a drawing. Let's say the user creates a global variable - the last name of the developer. In the title block of the format template, using the described functions, you can set the reading of the value of this variable. Thus, when inserting the formatting, part of the stamp will be filled in automatically.
For example: in the variable editor of one of the drawings, create a new variable of the appropriate type (real or text) and enter a function there that allows you to read a global variable of this type.
If a global variable with the specified name ("number") is present on this computer, then its value will be displayed in the field of the Value column. If the specified global variable is not found, then the value specified after the comma will be displayed in the field of the Value column.
In addition, a global variable can be created or changed its value in the usual variable editor or in any dialog where the use of variables is allowed. The functions are intended for this:
setg("Name", N) - sets the value of a real global variable;
tsetg("Name", N) - sets the value of the text global variable.
In this case, the first operand is the name of the global variable, and the expression after the comma determines the value of the global variable.
For example: in the variable editor, create a new variable ("var_2") and enter a function to set the value of the global variable.
If a global variable with the specified name already exists, then its value will be changed.
If a variable with the specified name does not exist, then it will be created and will appear in the main window of the global variables dialog.
If the drawing, in which the global variable was created using one of the setg or tsetg functions, is opened on another computer, then the same global variable will be automatically created at the new workstation.