Table Of Contents

Testing Sequences of Commands

Version:
    Last Modified: January 2, 2017

    Create MathScripts without a function definition to test sequences of commands without the overhead of defining a function with parameter values. In MathScripts without a function definition, you use global variables instead of parameter values. You can call MathScripts without a function definition from a MathScript Node, a user-defined function, another script, or from the MathScript Console. All elements must be in your project.

    The following procedure demonstrates how to create a MathScript without a function definition and how to call this script from the MathScript Console using a specific example. The example calculates the area of a triangle based on the given width and height. The steps you need to take to complete your specific task might be different than the following steps.

    1. In the Project Files tab, add a MathScript to your project.
    2. Delete the code function func().
    3. Enter the following code:
      A = (W*H)/2
    4. Select File»Save func.m to save the function.
    5. Select View»More»Tools Launcher to open the Tools Launcher.
    6. Click MathScript Console to open the MathScript Console.
    7. Enter the following code in the MathScript Console. Press Enter after every command.
      W = 34;
      H = 4;
    8. Enter func in the MathScript Console and press Enter.
      spd-note-note
      Note  

      You call a MathScript function by entering the file name without file extension.

      The workspace section of the MathScript Console shows the values for A, H and W.

    Recently Viewed Topics