OScript API/Built-in Package Index

Class: Core

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:

  • IsNotSet()
  • IsSet()
  • Point()
  • PointH()
  • PointV()

Class Attributes

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.

Class Methods

DatatypeName( Integer typeNumber )

For a type number, returns a String containing the corresponding type name.

Echo( [Dynamic firstValue] )

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)

EchoDebug( [Dynamic firstValue] )

Converts arguments to a string display format and emits the result to the debug/log output with a log level of DEBUG.

EchoError( [Dynamic firstValue] )

Converts arguments to a string display format and emits the result to the output/log with a log level of ERROR.

EchoInfo( [Dynamic firstValue] )

Converts arguments to a string display format and emits the result to the debug/log output with a log level of INFO.

EchoStamp( Boolean enable )

Enables/disables a timestamp prefix on Echo output.

EchoWarn( [Dynamic firstValue] )

Converts arguments to a string display format and emits the result to the output/log with a log level of WARN.

GetFeatures( Dynamic firstValue, [Boolean dummy] )
IsDefined( Dynamic testValue )

Determines whether a value is not Undefined.

IsError( Dynamic testValue, [Error compareValue] )

Determines whether a value is of datatype Error.

IsFeature( Dynamic object, Dynamic feature )

Indicates whether a value has the given feature.

IsInvokable( Dynamic testValue )

Indicates whether the specified value can be invoked.

IsNotError( Dynamic testValue, [Error compareValue] )

Determines whether a value is of datatype Error and, if so, optionally tests equality against another Error value.

IsNotSet( Dynamic testValue ) Deprecated

Determines whether a value is the special pseudo-value NotSet.

IsObject( Dynamic testValue )

Determines whether a value is of datatype Object.

IsSet( Dynamic testValue ) Deprecated

Determines whether a value is not the special pseudo-value NotSet.

IsUndefined( Dynamic testValue )

Determines whether a value is the special value Undefined.

Length( Dynamic value )

Returns the length of the specified value.

Returns the maximum Real value (in double precision).

Returns the minimum Real value (in double precision).

Parameters( [Integer whichArg] )

Access the actual parameter values from within the currently executing OScript function.

Point( Integer hCoord, Integer vCoord ) Deprecated

Construct a Point value from two coordinates.

PointH( Point somePoint ) Deprecated

Return the H coordinate from the specified point.

PointV( Point somePoint ) Deprecated

Return the V coordinate from the specified point.

SecurityLog( String message )

Writes a log message to the security log.

SecurityLogCreate( String message )

Sets the header string to the security log.

Determines if the security log exists.

SecurityLogSetHeader( String message )

Sets the header string to the security log.

SummaryTimingLog( String message )

Writes a log message to the summary timing log.

Determines if the summary timing log exists.

Type( Dynamic testValue )

Returns the datatype number corresponding to the type of the given value.

Class Attributes

Integer BooleanType

A constant indicating the datatype number of the datatype Boolean.

Integer BytesType

A constant indicating the datatype number of the datatype Bytes.

Integer DateType

A constant indicating the datatype number of the datatype Date.

Integer DynamicType

A constant indicating the datatype number of the pseudo-datatype Dynamic.

Integer ErrorType

A constant indicating the datatype number of the datatype Error.

Integer ExternType

A constant indicating the datatype number of the datatype Extern.

Boolean False

A constant indicating the Boolean constant FALSE.

Integer IntegerType

A constant indicating the datatype number of the datatype Integer.

Integer ListType

A constant indicating the datatype number of the datatype List.

Integer ObjectType

A constant indicating the datatype number of the datatype Object.

Integer ObjRefType

A constant indicating the datatype number of the datatype ObjRef.

Integer PointType

A constant indicating the datatype number of the datatype Point.

Integer RealType

A constant indicating the datatype number of the datatype Real.

Integer ScriptType

A constant indicating the datatype number of the datatype Script.

Integer StringType

A constant indicating the datatype number of the datatype String.

Boolean True

A constant indicating the Boolean value TRUE.

Undefined Undefined

A constant indicating the special value Undefined, which is of datatype Undefined.

Integer UndefinedType

A constant indicating the datatype number of the datatype Undefined.

Integer VoidType

A constant indicating the datatype number of the datatype void.

Class Methods

DatatypeName

String DatatypeName( Integer typeNumber )

For a type number, returns a String containing the corresponding type name. If there is no loaded type, then Undefined is returned.

Parameters

typeNumber

The datatype number.

Returns:

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.

Example

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

Echo

Void Echo( [Dynamic firstValue] )

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.

Parameters

firstValue

First value to be echoed/logged.

Returns:

Undefined

EchoDebug

Void EchoDebug( [Dynamic firstValue] )

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.

Parameters

firstValue

First value to be echoed/logged.

Returns:

Undefined

EchoError

Void EchoError( [Dynamic firstValue] )

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.

Parameters

firstValue

First value to be echoed/logged.

Returns:

Undefined

EchoInfo

Void EchoInfo( [Dynamic firstValue] )

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.

Parameters

firstValue

First value to be echoed/logged.

Returns:

Undefined

EchoStamp

Void EchoStamp( Boolean enable )

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.

Parameters

enable

True to enable the timestamp, false to disable.

Returns:

Undefined

EchoWarn

Void EchoWarn( [Dynamic firstValue] )

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.

Parameters

firstValue

First value to be echoed/logged.

Returns:

Undefined

GetFeatures

List GetFeatures( Dynamic firstValue,
                  [Boolean dummy] )

Internal use only.

Parameters

firstValue

First value.

dummy

Unused.

Returns:

A list.

IsDefined

Boolean IsDefined( Dynamic testValue )

Determines whether a value is not Undefined.

Parameters

testValue

The value to evaluate.

Returns:

FALSE if the value is Undefined, TRUE otherwise.

Example

Note that this will return TRUE for values of type Error.

IsError

Boolean IsError( Dynamic testValue,
                 [Error compareValue] )

Determines whether a value is of datatype Error and, if so, optionally tests equality against a second error value if compareValue is specified.

Parameters

testValue

Value to test.

compareValue

Value to compare.

Returns:

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.

IsFeature

Boolean IsFeature( Dynamic object,
                   Dynamic feature )

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.

Parameters

object

Object-like value

feature

Feature

Returns:

TRUE if the object has the specified feature, FALSE otherwise.

Example

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

IsInvokable

Boolean IsInvokable( Dynamic testValue )

Indicates whether the specified value can be invoked. Note that currently, only Script values are invokable.

Parameters

testValue

Value to examine for invokability.

Returns:

TRUE if the value can be invoked. FALSE otherwise.

IsNotError

Boolean IsNotError( Dynamic testValue,
                    [Error compareValue] )

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.

Parameters

testValue

Value to test

compareValue

Value to compare

Returns:

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.

IsNotSet

Deprecated
Boolean IsNotSet( Dynamic testValue )

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.

Parameters

testValue

Value to evaluate

Returns:

FALSE if the value is the special value returned by Assoc.NotSetValue(), TRUE otherwise.

IsObject

Boolean IsObject( Dynamic testValue )

Determines whether a value is of datatype Object.

Parameters

testValue

Value to evaluate

Returns:

TRUE if the value is of datatype Object, FALSE otherwise.

IsSet

Deprecated
Boolean IsSet( Dynamic testValue )

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.

Parameters

testValue

Value to evaluate

Returns:

TRUE if the value is not the special value returned by Assoc.NotSetValue(), FALSE otherwise.

IsUndefined

Boolean IsUndefined( Dynamic testValue )

Determines whether a value is the special value Undefined.

Parameters

testValue

Value to evaluate.

Returns:

TRUE if the value is Undefined, FALSE otherwise.

Length

Integer Length( Dynamic value )

Returns the length of the specified value.

Parameters

value

Value to return length of.

Returns:

The length of the specified value.

MaxReal

Real MaxReal()

Returns the maximum Real value.

Returns:

the maximum Real value.

MinReal

Real MinReal()

Returns the minimum Real value.

Returns:

the minimum Real value.

NParameters

Integer NParameters()

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.

Returns:

The number of actual and/or defaulted parameters passed to the current function.

Parameters

Dynamic Parameters( [Integer whichArg] )

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.

Parameters

whichArg

Index (1-based) of desired parameter

Returns:

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.

Example

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

Point

Deprecated
Point Point( Integer hCoord,
             Integer vCoord )

Construct a Point value from two coordinates. Note that the coordinate values must be between -32768 and +32767.

Parameters

hCoord

The H coordinate

vCoord

The V coordinate

Returns:

A Point value consisting of the specified coordinates.

PointH

Deprecated
Integer PointH( Point somePoint )

Return the H coordinate from the specified point.

Parameters

somePoint

Point value from which the H coordinate is to be extracted.

Returns:

The H coordinate of the specified point.

PointV

Deprecated
Integer PointV( Point somePoint )

Return the V coordinate from a Point value.

Parameters

somePoint

Point value from which the V coordinate is to be extracted.

Returns:

The V coordinate of the specified point.

SecurityLog

Void SecurityLog( String message )

Writes a log message to a security log.

Parameters

message

The string to be written to the security log.

Returns:

Undefined

SecurityLogCreate

Boolean SecurityLogCreate( String message )

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.

Parameters

message

The header string to be written at the beginning of each security log.

Returns:

TRUE if the security logger object was successfully created, FALSE otherwise.

Example

        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

SecurityLogExists

Boolean SecurityLogExists()

Determines if the security log exists. Returns TRUE if the security log file exists, else FALSE.

Returns:

TRUE if the security log exists, FALSE otherwise.

SecurityLogSetHeader

Boolean SecurityLogSetHeader( String message )

Sets the header string to the security log. The header string is a string that gets written at the beginning of each log file.

Parameters

message

The header string to be written at the beginning of each security log.

Returns:

TRUE if the header string was successfully set, FALSE otherwise, likely because the security log has not been created yet.

SummaryTimingLog

Void SummaryTimingLog( String message )

Creates a summary timing log and writes a log message.

Parameters

message

The string to be written to the summary timing log.

Returns:

Undefined

SummaryTimingLogExists

Boolean SummaryTimingLogExists()

Determines if the summary timing log exists. Returns TRUE if the summary timing log file exists, else FALSE.

Returns:

TRUE if the summary timing log exists, FALSE otherwise.

Type

Integer Type( Dynamic testValue )

Returns the datatype number indicating the type of the given value.

Parameters

testValue

Value for which the corresponding type number is returned.

Returns:

The datatype number for the specified value.

Example

Here is an example:

  String  x
  echo( Type( x ) )
  echo( DatatypeName( Type( x ) ) )

The output from the example is:

 -1
  String

 Copyright © 2023 OpenText Corporation. All rights reserved.