Company Events Academic Community Support Solutions Products & Services Contact NI MyNI

Creating Global Variables in LabVIEW MathScript (MathScript RT Module)

LabVIEW 2012 MathScript RT Module Help

Edition Date: June 2012

Part Number: 373123C-01

»View Product Info
Download Help (Windows Only)

Use the MathScript RT Module global function to create global variables in LabVIEW MathScript. Use global variables in MathScript to access and pass data between the LabVIEW MathScript Window and a MathScript Node or between two MathScript Nodes.

Note Note  The global function generates global variables in a separate context than the global variables in LabVIEW. For example, if you use the global function to generate the global variable a in MathScript, you also can create a different global variable a in LabVIEW.

Complete the following steps to create a global variable in the LabVIEW MathScript Window and then access the global variable from a MathScript Node.

  1. Call the following commands in the LabVIEW MathScript Window to define the variable a as global:

    a = 10;
    global a
  2. Open a new VI, and add a MathScript Node to the block diagram.

  3. Use the Operating or Labeling tool to enter the following script in the MathScript Node:

    global a
    b = a + 1

    As shown in the previous script, you must call the global function before you use the variable a. Otherwise, LabVIEW assumes a is a local variable and does not use the variable a you created in step 1.
  4. Add an output to the MathScript Node and create an indicator for the output.
    1. Right-click the right side of the MathScript Node frame and select Add Output»b from the shortcut menu.
    2. Right-click the b output terminal and select Choose Data Type»All Types»Scalar»U32 from the shortcut menu to configure the data type of the terminal.
    3. Right-click the b output terminal and select Create»Indicator from the shortcut menu to create an indicator labeled b.
  5. Right-click the error out output terminal and select Create»Indicator from the shortcut menu to create an error out indicator.
  6. Run the VI. LabVIEW invokes the MathScript RT Module server, adds 1 to the global variable a, and displays the result in the b indicator.

 

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit