Defining User Commands and Global Variables

DIAdem 2018 Help


Edition Date: June 2018
Part Number: 370858P-01
View Product Info

DOWNLOAD (Windows Only)


DIAdem 2017 Help
DIAdem 2018 Help
DIAdem 2019 Help
DIAdem 2020 Help
DIAdem 2020 SP1 Help

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:

  1. Select the DIAdem SCRIPT panel.

  2. Select File»New»VBS Script to create a new script file.

  3. 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
  4. Select File»Save As.

  5. Enter the filename MyUserCommand.vbs.

  6. Click Close.

  7. Select Settings»Extensions»User Commands»Add, to add the new user command file.

  8. Select the saved file MyUserCommand.vbs.

  9. Click Open

  10. 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

WAS THIS ARTICLE HELPFUL?

Not Helpful