NXM Help RESULTS

From ICE Enterprises
Jump to navigation Jump to search
Go to the full list of NXM Help pages.

RESULTS - Results table for working variables

If you are familiar with other version of Midas, such as X-Midas, the results parameters of NeXtMidas will have a few surprises. The results table can hold ANY object, including tables of other objects. These objects can be queried for internal information or controlled via its set methods. The results table serves an a near transparent interface between the macro language and the macro's component primitives.

SCOPE - global and local scope within the macro language

ATOMIC - Atomic results are results parameters with more than one numeric element.

Atomic results are results parameters with more than one numeric element. All Midas files have atomic formats such as SF, VD, or CF. The results table can be used to store any atomic format that is supported by the file system along with any arbitrarily sized array of scalars. For example:

res myres  myfile(201)

will create a 3 element results parameter of type D because myfile contains elements of the VD atomic format, such as a position in space vector. The shell also supports the (X,Y,Z,..) syntax for specifying an atomic result. For example:

res myres (0.5,3.3)

creates a result of type CD or complex double, or:

res myres (1,2,3,4,5,6,7,8,9,10)

creates an array of 10 numbers in the results table.

There is not much one can do with a 10 element array directly from the shell, however, each element of the array can be accessed separately using an array element syntax such as is used in the following calc statement:

calc myres(3) myres(4)+myres(5) myres(6) /

which modifies the 3rd element of the result myres based on an expression using other elements of the result. Note that to access a single element of an atomic result, the result must already exist and not be a scalar. This restriction is necessary to avoid confusion with vector results files which are discussed in HELP VECTORED.

An "abscissa mode" syntax can also be used for complex and vector sized atomic results. For example if myres is a complex result:

say "The real part is ^myres(~R) and the imaginary is ^myres(~I)"

The following labels are recognized:

~R is real part of complex   - same as 1
~I is imaginary of complex   - same as 2
~X is x-dimension of vector  - same as 1
~Y is y-dimension of vector  - same as 2
~Z is z-dimension of vector  - same as 3

It is sometimes more readable in macro code to use the "abscissa" syntax.

The atomic element syntax can also be used in conjunction with vectored results files by adding an extra semicolon followed by the atomic element number within the parenthesis of the vectored results syntax. For instance, to reference the X-dimension of the Nth file element of the position component in myfile, one could use the syntax:

say "The ^{N}th element's X-position is ^myfile(N;~POS;~X) meters" 

If atomic result appear in in-line expressions without an atomic element syntax specifying one of the elements, the magnitude is used for complex and vector sized results and the 1st element for all other sized results. To perform arithmetic operations on complex atomic results, use the calculator intrinsic command (see EXPLAIN CALCULATOR).

Note: Typecasting of atomic results is supported both on input and output but does not allow modecasting. (i.e. Complex can not be cast to Vector) Mode casting can be performed by using the atomic element syntax and the RESULTS or CALCULATOR commands if really necessary.

Note: Results attributes can only be applied to atomic results parameters has a whole (i.e. it is not possible to make only the second integer in a VI results parameter read-only). Any assignment of results attributes to an atomic result's index will affect all indices of the atomic results parameter.


TYPECASTING - GETTING TYPECAST

GETTING TYPECAST

There are six types of results: One STRING type and five numeric types (see HELP RESULTS). Usually, the type of the result is implied. In the following:

nM> res abc 123

the result ABC will end up Double precision, because 123 can be interpreted as a number. Conversely,

nM> res def MYSTRING

will make DEF an STRING results parameter, since "MYSTRING" cannot be interpreted as any kind of number (assuming you do not have a numeric result parameter named MYSTRING). But you can force the result to take any type you like, by prefixing it with the first letter of the type and a colon. Thus,

nM> res b:abc 123

will store 123 into ABC as type Byte. This becomes more useful when making the distinction between STRING, which translates if possible, and Untranslated, which never translates. (See HELP RESULTS for a discussion of X-Midas types.) Given the above definitions,

nM> res abc def

will assign "MYSTRING" to ABC, since DEF could be translated, while

nM> res u:abc def

will assign "DEF" to ABC.

The most useful aspect of this convention is that it is not controlled by the RESULTS command but by the shell; you can do explicit typecasting anyplace that a result is stored or set. For example,

nM> status sine1 i:sinesize

will force SINESIZE to have an Integer type, even though STATUS normally stores a Double precision value into a file size result. If you like, you can even force STATUS to store an STRING result:

nM> status/quiet sine1 s:sinesize
nM> res sinesize
4S: SINESIZE        = 4096

The typecasting syntax is used as a filter for displaying results parameters. For example, the following command will display all Long integer results parameters beginning with M:

nM> res l:m*


See also: HELP RESULTS