The following pages list global class functions from PRIMER which can be used in D3PLOT.
Most of the D3PLOT functions are also in the global scope, but to make them easier to locate, they are presented in different categories (e.g. Contacts, CutSection, Data) in subsequent sections. They are also listed below in alphabetical order.
Details of functionsAllocateFlag() [static]DescriptionAllocate a flag for use in the script. See also ReturnFlag(). Once allocated the flag is automatically cleared for all the models currently in D3PLOT. |
No arguments
ReturnsFlag to use Return typeFlag |
ExampleTo allocate a flag var flag = AllocateFlag();
|
DialogueInput(command[string]) [static]Description
Executes one or more command-line syntax commands. There is no limit to the number of lines that may be specified in a single call. See Dialogue Command Syntax for a full list of command-line commands The DialogueInputNoEcho variant is identical, except that it suppresses the echo of the commands to the dialogue box. D3PLOT provides a full command-line syntax as an alternative to graphical user interface commands, and a sequence of such commands may be provided here. Note that:
Therefore commands which require more than one line of input to complete must be specified in a single call; and it makes sense to group a sequence of related commands together in a single call, although this is not mandatory. If this succeeds it returns true, otherwise false. |
Command to be executed (as if it had been typed into the dialogue box)
This argument can be repeated if required
Alternatively a single array argument containing the multiple values can be given
ReturnsNo return value |
DialogueInputNoEcho(command[string]) [static]Description
Executes one or more command-line syntax commands. There is no limit to the number of lines that may be specified in a single call. See Dialogue Command Syntax for a full list of command-line commands This does not echo the commands to the dialogue box. See DialogueInput for more information. |
Command to be executed (as if it had been typed into the dialogue box)
This argument can be repeated if required
Alternatively a single array argument containing the multiple values can be given
ReturnsNo return value |
ErrorMessage(string[Any valid javascript type]) [static]DescriptionPrint an error message to the dialogue box adding a carriage return. |
The string/item that you want to print
ReturnsNo return value |
ExampleTo print the title of model object m as an error to the dialogue box ErrorMessage("The title is " + m.title);
|
Execute(data[object]) [static]DescriptionExecute a program or script outside D3PLOT and get the standard output and error streams. |
Execute data
Object has the following properties:
| Name | Type | Description |
| arguments (optional) | Array of strings | The arguments to pass to program |
| program | string | The program you want to run. Note that on Linux this will consider PATH when resolving executable filenames without an absolute path. If you want to run something from the current directory and you do not have '.' in your PATH then you will need to write './something' as the program. |
Returns |
Object with the following properties:
| Name | Type | Description |
| status | integer | The exit code from the program/script |
| stderr | string | The standard error output from the program/script |
| stdout | string | The standard output from the program/script |
object
Exit(write hook interrupt (optional)[boolean]) [static]DescriptionExit script |
If Exit() is called from a write_hook.js script, the first argument will be processed as in the following: If the argument is provided and set to "true", it is used to interrupt the write out of the model, so that the script exits without anything being written out. An argument value of "false" exits the script and allows the model to be written out as normal. An example of this function's use in a Write Hook script can be found at $OA_INSTALL/primer_library/scripts/hooks/example_write_hook.js.
ReturnsNo return value |
ExampleExit with Exit();
|
ExitTHisLink() [static]DescriptionExits the T/HIS link from D3PLOT |
No arguments
ReturnsNo return value |
GetCurrentDirectory() [static]DescriptionGet the current working directory |
No arguments
ReturnsString containing current working directory Return typeString |
ExampleTo get the current directory: var cwd = GetCurrentDirectory();
|
No arguments
Returnsstring Return typeString |
ExampleTo get the install directory: var install_dir = GetInstallDirectory();
|
The program name string : Valid values are 'All', 'D3PLOT', 'PRIMER', 'REPORTER', 'SHELL',
'T/HIS'
The preference name string
ExampleTo get the preference value: var pref_list = GetPreferenceValue('All', "font_size");
|
GetStartInDirectory() [static]DescriptionGet the directory passed to D3PLOT by the -start_in command line argument |
No arguments
ReturnsString containing start_in directory or NULL if not set Return typeString |
ExampleTo get the start_in directory: var start_in = GetStartInDirectory();
|
Getenv(name[string]) [static]DescriptionGet the value of an environment variable |
The environment variable name
ReturnsString containing variable value or null if variable does not exist Return typeString |
ExampleTo get the value for environment variable HOME var home = Getenv("HOME");
|
Message(string[Any valid javascript type]) [static]DescriptionPrint a message to the dialogue box adding a carriage return. |
The string/item that you want to print. If '\r' is added to the end of the string then instead of automatically adding a carriage return in the dialogue box, the next message will overwrite the current one. This may be useful for giving feedback to the dialogue box when doing an operation.
ReturnsNo return value |
ExampleTo print the title of model object m as a message to the dialogue box Message("The title is " + m.title);
|
MilliSleep(time[integer]) [static]DescriptionPause execution of the script for time milliseconds. See also Sleep() |
Number of milliseconds to pause for
ReturnsNo return value |
ExampleTo pause for 500 milliseconds MilliSleep(500);
|
NumberToString(number[integer/real], width[integer], pref_int (optional)[boolean]) [static]DescriptionFormats a number to a string with the specified width. |
The number you want to format.
The width of the string you want to format it to (must be less than 80).
By default only integer values inside the single precision 32 bit signed integer limit of approximately +/-2e9 are formatted as integers, all other numeric values are formatted as floats. With this argument set to TRUE then integer values up to the mantissa precision of a 64 bit float, approximately +/-9e15, will also be formatted as integers.
ReturnsString containing the number Return typeString |
ExampleTo write the number 1.2345e+6 to a string 10 characters wide var str = NumberToString(1.2345e+6, 10);
|
OpenManual(program[string], page[string]) [static]DescriptionOpen the Oasys manuals at a requested page |
The program manual to open. Can be "primer", "d3plot" or "this"
The page to open in the manual, e.g. "running-this.html"
Returnstrue if successful, false if not Return typeBoolean |
ExampleTo open the T/HIS manual on the running-this.html page OpenManual("this", "running-this.html");
|
Print(string[Any valid javascript type]) [static]DescriptionPrint a string to stdout. Note that a carriage return is not added. |
The string/item that you want to print
ReturnsNo return value |
ExampleTo print string "Hello, world!" Print("Hello, world!");To print the title of model object m with a carriage return print("The title is " + m.title + "\n");
|
Println(string[Any valid javascript type]) [static]DescriptionPrint a string to stdout adding a carriage return. |
The string/item that you want to print
ReturnsNo return value |
ReturnFlag(flag[Flag]) [static]DescriptionReturn a flag used in the script. See also AllocateFlag(). |
The flag to return
ReturnsNo return value |
ExampleTo return flag f: ReturnFlag(f);
|
SetCurrentDirectory(directory path[string]) [static]DescriptionSets the current working directory. |
Path to the directory you would like to change into.
Returnstrue if successful, false if not Return typeBoolean |
ExampleTo change into the directory "/data/test" exists SetCurrentDirectory("/data/test")
|
Sleep(time[integer]) [static]DescriptionPause execution of the script for time seconds. See also MilliSleep() |
Number of seconds to pause for
ReturnsNo return value |
ExampleTo pause for 2 seconds Sleep(2);
|
StartTHisLink() [static]DescriptionStarts the T/HIS link from D3PLOT |
No arguments
ReturnsNo return value |
System(string[Any valid javascript type]) [static]DescriptionDo a system command outside D3PLOT. To run an external command and get the output then please use Execute() instead. |
The system command that you want to do
Returnsinteger (probably zero if command successful but is implementation-dependant) Return typeNumber |
ExampleTo make the directory "example" System("mkdir example");
|
Unix() [static]DescriptionTest whether script is running on a Unix/Linux operating system. See also Windows() |
No arguments
Returnstrue if Unix/Linux, false if not Return typeBoolean |
ExampleTo test if the OS is Unix if ( Unix() )
|
WarningMessage(string[Any valid javascript type]) [static]DescriptionPrint a warning message to the dialogue box adding a carriage return. |
The string/item that you want to print
ReturnsNo return value |
ExampleTo print the title of model object m as a warning to the dialogue box WarningMessage("The title is " + m.title);
|
Windows() [static]DescriptionTest whether script is running on a Windows operating system. See also Unix() |
No arguments
Returnstrue if Windows, false if not Return typeBoolean |
ExampleTo test if the OS is Windows if ( Windows() )
|