Download D3PLOT 10.0 user manual

Transcript
User manual Version 10.0, June 2011
D3PLOT
Notes on programming:
All scripts and script runs are independent
Javascript variables and "current" settings are not "remembered" in any way across successive executions of
scripts. Each script, including a second and subsequent execution of the same compiled script, is wholly
independent; and default current model, window and other values are reset every time a script is executed.
Argument types:
Javascript is a very weakly typed language in which data can be thought of as "numbers", "strings", "arrays",
"objects" and so on. However when describing a function it is useful to be more precise about the sort of
argument expected or returned, and the following descriptions are used below.
A "whole number" which would qualify as an integer in languages such as Fortran or C.
A "floating point number". Javascript does all floating point arithmetic in double precision, so there
is no concept of a single precision "float".
Boolean Either JS_TRUE or JS_FALSE. Typically this is the success/failure status outcome of function
calls that do not return a data value. It does not translate to a "number", and should only be used for
logical tests.
String
A string of one or more characters in "..". For example "this is a string".
<type>
An array of values of <type>. Javascript does not assign types to arrays, and their subscripts may be
Array
of mixed type, however in the context of this API arrays will be of a single type, eg integer,
which will be specified.
Object
Javascript objects may be of any type, and members may be added at will. In the context of this
API they will be classes, and the class members will be specified.
Constant Will be a capitalised constant value from a defined list (eg DX, SOLID, etc), effectively an
integer. All valid constants for this API are listed in the Table of Valid Constants below.
A common error is to pass an argument that is a String to a function below that expects a "number" of some
sort, typically when data has been read from an external file and processed using string manipulation functions.
This will generate a "wrong type of argument" error when the function executes.
Integer
Double
The solution is to use one of the Javascript conversion functions Number(xxx), ParseInt(xxx) or
ParseFloat(xxx) to convert the string to a number.
Compulsory and optional arguments:
Many functions have optional arguments. These will always be the trailing arguments and they will be written
italicised and placed in brackets in the function description. For example:
integer DemoFunction(arg_1, arg_2, (arg_3), (arg_4))
<arg_1> and <arg_2> are compulsory.
<arg_3> and <arg_4> are optional and may be omitted.
However if an optional argument is to be specified then any other optional arguments that precede must also be
supplied. For example in the example above if <arg_4> is to be specified then <arg_3> must also be supplied
even if it has the default value of zero.
Unless specified otherwise below a value of zero can be used for any optional argument that has to be supplied
but is to be ignored.
Return values:
All functions in this API return a value, although you are free to ignore this. As a general rule those that
"GetXxxx" something return an integer, double, array or object as a result, and others return the boolean value
JS_TRUE or JS_FALSE to denote success or failure. Each function’s return type is documented below, and will
be one of:
Page A.33