Defining User Commands and Global Variables
- Updated2024-09-12
- 2 minute(s) read
Creating Scripts > User Commands and User Variables > Defining User Commands and Global Variables
Defining User Commands and Global Variables
Use user commands to include your own commands in DIAdem or to redefine existing commands. You can use user commands, for example, to format text in the panel DIAdem REPORT, in the Calculator, in scripts, or to add your own commands to DIAdem menus. To define user commands and global variables, complete the following steps:
-
Select the DIAdem SCRIPT panel.
-
Select File»New»VBS Script to create a new script file.
-
Enter or copy the following text into the script editor:
Dim strUnit Function CelsiusToFahrenheit(dblCelsius) CelsiusToFahrenheit = 32 + 9/5 * dblCelsius strUnit = "Fahrenheit" End Function Function FahrenheitToCelsius(dblFahrenheit) FahrenheitToCelsius = 5/9 * (dblFahrenheit - 32) strUnit = "Celsius" End Function
-
Select File»Save As.
-
Enter the filename MyUserCommand.vbs.
-
Click Close.
-
Select Settings»Extensions»User Commands»Add, to add the new user command file.
-
Select the saved file MyUserCommand.vbs.
-
Click Open.
-
Click Close in the user command dialog box.
The two functions and the strUnit variable, which you defined in the user command file MyUserCommand.vbs, are now available everywhere in DIAdem. You can use the functions, for example, to convert and format the values of a table everywhere in the table. For example, to display values, which were measured in degrees Fahrenheit, in degrees Celsius, enter the expression @@CelsiusToFahrenheit(CurrFormatValue)@@ @@strUnit@@ as the format on the Column Properties tab in the table definition dialog box.
| Note You also can define user command files in sub-procedures and classes. | |
| Note You can also call user commands recursively. |
Examples
Using User Commands for Extended Numeric Display | Using User Commands for Trend Displays in Tables | Using User Commands to Format a Date