Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI
This Document is not yet Rated  Rate this Document

Differences Between MathScript Files In MATRIXx

Primary Software: MATRIXx
Primary Software Version: 7.1
Primary Software Fixed Version: N/A
Secondary Software: N/A

Problem:
What are the differences between the different types of MathScript files in MATRIXx?

Solution:
MathScript (.ms) Files .- It is an ASCII file of Xmath commands and functions. MathScript files do not take any arguments to run (unlike MSCs), and they do not explicitly return outputs (unlike MSFs). The MathScript file executes as if you typed the commands. Variables created by the MathScript file are created in current partition and remain available after the script runs. Script files are particularly useful for customizing a work environment or for storing a set of commands which will be used repeatedly.
To execute the file type

execute file = "myfile"

Or go to File>Execute and select the .ms file from the dialog. MathScript Files (.ms) are easy to write, but not as easy to use or as fast as MSCs or MSFs.

MathScript Command (.msc) files .- It is an ASCII text file that contains MathScript statements and defines a command. The filename must be the same as the command name, with a file extension of .msc. When an MSC is first used inside Xmath, the ASCII text file ending with .msc is compiled into a binary executable file ending with .xc. This binary file is then executed every time the command is called. The MathScript Command will execute in a separate partitions, so variables created in the command will not affect variables in the working partition.
The content of such file should conform the following template:

#{ Introductory comment that is also
the help for the command, available by typing
help mycommand after the function has been compiled }#

command mycommand argument1 argument2
**your Xmath commands **
endcommand

To execute an MSC, type the name of the command with any arguments it may have.

mycommand argument1 argument2


MathScript Function (.msf) Files.- It is an ASCII text file that contains MathScript statements and defines a function. The file name must be the same as the function name, with a file extension of .msf. By definition a function operates on the inputs to create outputs. When an MSF is first used inside Xmath, the ASCII text file ending with .msf is compiled into a binary executable file ending with .xf. This binary file is then executed every time the function is called. The MathScript Function will execute in a separate partitions, so variables created in the function will not affect variables in the working partition.
The contents of an MSF file must conform to the following template:

#{ Introductory comment that is also
the help for the function, available by typing
help myfun after the function has been compiled }#

Function [Out1,...,OutN]= myFun(In1,...,InN...)
** Your Xmath Commands**
endfunction

To execute an MSF, type the name of the output and the function with the arguments.

[out1, out2]= myfunction (in1, in2)

Use functions when a return value is needed, otherwise, use commands. Command and Functions Files are for long-term, more general needs and because they are compiled code, they are faster than the MathScript (.ms) files. For more information see the Xmath Users Guide as well as the Online Help. Type help mathscript in Xmath.


Related Links: Xmath User Guide

Attachments:





Report Date: 11/08/2005
Last Updated: 11/08/2005
Document ID: 3R78RLRY

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit