The global class is the main JavaScript class. More...
The T/HIS JavaScript API provides many class constants, properties and methods. For Arup to
be able to extend and enhance the API in the future any constant, property or method names beginning with a lowercase
or uppercase letter are reserved.
If you need to add your own properties or methods to one of the existing classes then to avoid any potential future conflict you
should ensure that the name begins with either an underscore (_) or a dollar sign ($) or the name is prefixed with your
own unique identifier.
For example if company 'ABC' need to add a property called 'example' then to avoid any potential future conflict use one of:
Detailed DescriptionThe global class declares the global object in JavaScript that contains the global properties and methods. As well as the core JavaScript methods, T/HIS also defines other additional ones. e.g. Message(), Print() etc. See the documentation below for more details. |
Details of functionsAllocateFlag() [static]DescriptionAllocate a flag for use in the script. See also ReturnFlag() and Once allocated the flag is automatically cleared for all entity types and all the curves currently in T/HIS. |
No arguments
ReturnsFlag (integer) Return typeNumber |
ExampleTo allocate a flag var flag = AllocateFlag();
|
ClearFlag(flag[Flag]) [static]DescriptionClears a flag on all curves and entity types. |
The flag to return.
ReturnsNo return value. |
ExampleTo clear flag f: ClearFlag(f);
|
DialogueInput(command[string]) [static]DescriptionExecute one or more lines of command line dialogue input. |
Command to execute (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]DescriptionExecute one or more lines of command line dialogue input with no echo of commands to dialogue box. |
Command to execute (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 |
DisableGraphWindowUpdates() [static]DescriptionDisable Graph Window updates. |
No arguments
ReturnsNo return value |
ExampleTurn off graph window updates DisableGraphWindowUpdates();
|
DisableMenuUpdates() [static]DescriptionDisable menu system updates. |
No arguments
ReturnsNo return value |
ExampleDisable menu system updates DisableMenuUpdates();
|
EnableGraphWindowUpdates() [static]DescriptionEnable Graph Window updates. |
No arguments
ReturnsNo return value |
ExampleTurn off graph window updates EnableGraphWindowUpdates()
|
EnableMenuUpdates() [static]DescriptionEnable menu system updates. |
No arguments
ReturnsNo return value |
ExampleEnable menu system updates EnableMenuUpdates();
|
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 T/HIS 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();
|
GetCurrentDirectory() [static]DescriptionGet the current working directory |
No arguments
ReturnsString containing current working directory Return typeString |
ExampleTo get the current directory: var cwd = GetCurrentDirectory();
|
GetFtcfVar(name[string]) [static]DescriptionGet the value of a FAST-TCF variable |
The FAST-TCF variable name (case independent)
ReturnsString containing variable value or null if variable does not exist Return typeString |
ExampleTo get the value for FAST-TCF variable Job var job_name = GetFtcfVar("Job");
|
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 T/HIS 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");
|
Plot() [static]DescriptionUpdates all the T/HIS graphs. |
No arguments
ReturnsNo return value |
ExampleUpdate all graphs Plot();
|
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() and |
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")
|
SetFtcfVar(name[string]) [static]DescriptionSet the value of a FAST-TCF variable. If the variable already exists then it's value is updated |
The FAST-TCF variable name (case independent)
ReturnsString containing variable value or null if variable does not exist Return typeString |
ExampleTo create a new FAST-TCF variable called run_number with the value "10" var home = SetFtcfVar("run_number","10");
|
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);
|
System(string[Any valid javascript type]) [static]DescriptionDo a system command outside T/HIS. 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() )
|
No arguments
ReturnsNo return value |
ExampleUpdate curve slider UpdateCurveMenu();
|
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() )
|