OScript API/Built-in Package Index |
The Core class contains a set of functions and constants that are integral to the effective use of OScript. For all intents and purposes, these entities are intrinsics in the language, which is why no class prefix is required when using them.
Most of the Core methods and attributes deal with the dynamic datatypes available within OScript, including comparison and testing of these datatypes, as well as a variety of constants indicating the datatype numbers of the builtin types.
A bit of background on OScript's dynamic datatyping might be in order here. Every value within OScript has a specific datatype associated with it. This datatype determines the behavior of the value within the OScript environment; for example, Strings behave decidedly different than Integers. Associated with each datatype is a datatype name and an integer. Given a value, the type number can be obtained with the Type() function. Given a type number, the name can be obtained with the DatatypeName() function. The Core class contains constants corresponding to the type numbers for various basic types (such as IntegerType, StringType, ListType).
In addition, there are a few miscellaneous functions that are in the intrinsic Core package for unfortunate historical reasons:
A constant indicating the datatype number of the datatype Boolean.
A constant indicating the datatype number of the datatype Bytes.
A constant indicating the datatype number of the datatype Date.
A constant indicating the datatype number of the datatype Dynamic.
A constant indicating the datatype number of the datatype Error.
A constant indicating the datatype number of the datatype Extern.
A constant indicating the Boolean value FALSE.
A constant indicating the datatype number of the datatype Integer.
A constant indicating the datatype number of the datatype List.
A constant indicating the datatype number of the datatype Object.
A constant indicating the datatype number of the datatype ObjRef.
A constant indicating the datatype number of the datatype Point.
A constant indicating the datatype number of the datatype Real.
A constant indicating the datatype number of the datatype Script.
A constant indicating the datatype number of the datatype String.
A constant indicating the Boolean value TRUE.
A constant indicating the Undefined value Undefined.
A constant indicating the datatype number of the datatype Undefined.
A constant indicating the datatype void.
For a type number, returns a String containing the corresponding type name.
Converts arguments to a string display format and emits the result to the debug/log output with a log level of INFO. (Alias of EchoInfo)
Converts arguments to a string display format and emits the result to the debug/log output with a log level of DEBUG.
Converts arguments to a string display format and emits the result to the output/log with a log level of ERROR.
Converts arguments to a string display format and emits the result to the debug/log output with a log level of INFO.
Enables/disables a timestamp prefix on Echo output.
Converts arguments to a string display format and emits the result to the output/log with a log level of WARN.
Determines whether a value is not Undefined.
Determines whether a value is of datatype Error.
Indicates whether a value has the given feature.
Indicates whether the specified value can be invoked.
Determines whether a value is of datatype Error and, if so, optionally tests equality against another Error value.
Determines whether a value is the special pseudo-value NotSet.
Determines whether a value is of datatype Object.
Determines whether a value is not the special pseudo-value NotSet.
Determines whether a value is the special value Undefined.
Returns the length of the specified value.
Returns the maximum Real value (in double precision).
Returns the minimum Real value (in double precision).
Access the actual parameter values from within the currently executing OScript function.
Construct a Point value from two coordinates.
Return the H coordinate from the specified point.
Return the V coordinate from the specified point.
Writes a log message to the security log.
Sets the header string to the security log.
Determines if the security log exists.
Sets the header string to the security log.
Writes a log message to the summary timing log.
Determines if the summary timing log exists.
Returns the datatype number corresponding to the type of the given value.
A constant indicating the datatype number of the datatype Boolean.
A constant indicating the datatype number of the datatype Bytes.
A constant indicating the datatype number of the datatype Date.
A constant indicating the datatype number of the pseudo-datatype Dynamic.
A constant indicating the datatype number of the datatype Error.
A constant indicating the datatype number of the datatype Extern.
A constant indicating the Boolean constant FALSE.
A constant indicating the datatype number of the datatype Integer.
A constant indicating the datatype number of the datatype List.
A constant indicating the datatype number of the datatype Object.
A constant indicating the datatype number of the datatype ObjRef.
A constant indicating the datatype number of the datatype Point.
A constant indicating the datatype number of the datatype Real.
A constant indicating the datatype number of the datatype Script.
A constant indicating the datatype number of the datatype String.
A constant indicating the Boolean value TRUE.
A constant indicating the special value Undefined, which is of datatype Undefined.
A constant indicating the datatype number of the datatype Undefined.
A constant indicating the datatype number of the datatype void.
For a type number, returns a String containing the corresponding type name. If there is no loaded type, then Undefined is returned.
The datatype number.
A String containing the name of the type specified by typeNumber. If the specified type number does not correspond to a loaded type, this will return Undefined.
This is intended to be used for debugging purposes and in conjunction with Core.Type().
Here is an example:
String x echo( DatatypeName( Type( x ) ) )
The output from the example is:
String
Converts arguments to a string display format and emits the result to the debug/log output with a level of INFO. This function terminates its output with a newline. If no arguments are specified, then only a newline is emitted. A maximum of 127 arguments can be passed. This method is an alias of EchoInfo.
First value to be echoed/logged.
Undefined
Converts arguments to a string display format and emits the result to the debug/log output with a level of DEBUG. This function terminates its output with a newline. If no arguments are specified, then only a newline is emitted. A maximum of 127 arguments can be passed.
First value to be echoed/logged.
Undefined
Converts arguments to a string display format and emits the result to the debug/log output with a level of ERROR. This function terminates its output with a newline. If no arguments are specified, then only a newline is emitted. A maximum of 127 arguments can be passed.
First value to be echoed/logged.
Undefined
Converts arguments to a string display format and emits the result to the debug/log output with a level of INFO. This function terminates its output with a newline. If no arguments are specified, then only a newline is emitted. A maximum of 127 arguments can be passed.
First value to be echoed/logged.
Undefined
Enables/disables a timestamp prefix for all Echo output. When enabled, a timestamp will be prepended to all Echo, EchoError, EchoDebug, and EchoWarn statements in the format "mm/dd/YYY HH:MM:SS [ssss] ", where ssss is the current system tick count in microseconds.
True to enable the timestamp, false to disable.
Undefined
Converts arguments to a string display format and emits the result to the debug/log output with a level of WARN. This function terminates its output with a newline. If no arguments are specified, then only a newline is emitted. A maximum of 127 arguments can be passed.
First value to be echoed/logged.
Undefined
Internal use only.
First value.
Unused.
A list.
Determines whether a value is not Undefined.
The value to evaluate.
FALSE if the value is Undefined, TRUE otherwise.
Note that this will return TRUE for values of type Error.
Determines whether a value is of datatype Error and, if so, optionally tests equality against a second error value if compareValue is specified.
Value to test.
Value to compare.
If called with one argument, then this function returns TRUE if the type of the argument is Error. If called with two arguments, then this returns TRUE if both arguments are of type Error and are identical.
Indicates whether a value has the given feature. Note that this function applies to any datatype that can be dotted (e.g., Record, Assoc, Object) and it performs the appropriate type-specific function.
Object-like value
Feature
TRUE if the object has the specified feature, FALSE otherwise.
This function has a type-specific equivalent function for most datatypes. The following table illustrates these equivalents:
Here is an example:
Assoc a = Assoc.CreateAssoc() a.someKey = "Hello" if IsFeature( a, "someKey" ) echo( "Yes" ) else echo( "No" ) end
The output from the example is:
Yes
Indicates whether the specified value can be invoked. Note that currently, only Script values are invokable.
Value to examine for invokability.
TRUE if the value can be invoked. FALSE otherwise.
Determines whether a value is of datatype Error and optionally compares two error values for equality. If compareValue is specified, then it is compared with testValue.
Value to test
Value to compare
If a single argument is specified, this returns FALSE if testValue is of datatype Error. If both arguments are specified, this will return FALSE if testValue is of datatype Error and is equal to compareValue. This function will return TRUE otherwise.
Determines whether a value is the special pseudo-value NotSet. This value is a special value used in conjunction with Assoc. See Assoc.NotSetValue() for more information.
Value to evaluate
FALSE if the value is the special value returned by Assoc.NotSetValue(), TRUE otherwise.
Determines whether a value is of datatype Object.
Value to evaluate
TRUE if the value is of datatype Object, FALSE otherwise.
Determines whether a value is not the special pseudo-value NotSet. This value is a special value used in conjunction with Assoc. See Assoc.NotSetValue() for more information.
Value to evaluate
TRUE if the value is not the special value returned by Assoc.NotSetValue(), FALSE otherwise.
Determines whether a value is the special value Undefined.
Value to evaluate.
TRUE if the value is Undefined, FALSE otherwise.
Returns the length of the specified value.
Value to return length of.
The length of the specified value.
Indicates the number of actual parameters passed to the current function. Useful when variable argument lists are used. Note that defaulted parameters count as parameters with respect to this function.
The number of actual and/or defaulted parameters passed to the current function.
Access the actual parameter values from within the currently executing OScript function. This is especially useful with variable argument lists, since it permits unnamed parameters to be examined.
Index (1-based) of desired parameter
If no index is specified, then this will return a list of the actual parameters passed to the current function. If an index is specified, then the parameter with the given index will be returned. If an out-of-bounds index is specified, this function will return Undefined.
Here is an example:
function void main() joe( 1 ) joe( 1, 2 ) joe( 1, 2, 3 ) end function void joe( Integer a, Integer b = 5, ... ) echo( "NParameters()=", NParameters() ) echo( "Parameters()=", Parameters() ) echo( "Parameters( 3 )=", Parameters( 3 ) ) echo() end
The output from the example is:
NParameters()=2 Parameters()={1,5} Parameters( 3 )=? NParameters()=2 Parameters()={1,2} Parameters( 3 )=? NParameters()=3 Parameters()={1,2,3} Parameters( 3 )=3
Construct a Point value from two coordinates. Note that the coordinate values must be between -32768 and +32767.
The H coordinate
The V coordinate
A Point value consisting of the specified coordinates.
Return the H coordinate from the specified point.
Point value from which the H coordinate is to be extracted.
The H coordinate of the specified point.
Return the V coordinate from a Point value.
Point value from which the V coordinate is to be extracted.
The V coordinate of the specified point.
Writes a log message to a security log.
The string to be written to the security log.
Undefined
Creates the security logger object and inititalize it with a header string. The header string is a string that gets written at the beginning of each log file.
The header string to be written at the beginning of each security log.
TRUE if the security logger object was successfully created, FALSE otherwise.
if ( !SecurityLogExists() ) // Create the log SecurityLogCreate( "This is the header string." ) end if( SecurityLogExists() ) // Write out a log message SecurityLog( " This is a log message " ) end
Determines if the security log exists. Returns TRUE if the security log file exists, else FALSE.
TRUE if the security log exists, FALSE otherwise.
Sets the header string to the security log. The header string is a string that gets written at the beginning of each log file.
The header string to be written at the beginning of each security log.
TRUE if the header string was successfully set, FALSE otherwise, likely because the security log has not been created yet.
Creates a summary timing log and writes a log message.
The string to be written to the summary timing log.
Undefined
Determines if the summary timing log exists. Returns TRUE if the summary timing log file exists, else FALSE.
TRUE if the summary timing log exists, FALSE otherwise.
Returns the datatype number indicating the type of the given value.
Value for which the corresponding type number is returned.
The datatype number for the specified value.
Here is an example:
String x echo( Type( x ) ) echo( DatatypeName( Type( x ) ) )
The output from the example is:
-1 String
Copyright © 2021 OpenText Corporation. All rights reserved. |