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:
Integer BooleanType
A constant indicating the datatype number of the datatype Boolean.
BytesTypeInteger BytesType
A constant indicating the datatype number of the datatype Bytes.
DateTypeInteger DateType
A constant indicating the datatype number of the datatype Date.
DynamicTypeInteger DynamicType
A constant indicating the datatype number of the pseudo-datatype Dynamic.
ErrorTypeInteger ErrorType
A constant indicating the datatype number of the datatype Error.
ExternTypeInteger ExternType
A constant indicating the datatype number of the datatype Extern.
FalseBoolean False
A constant indicating the Boolean constant FALSE.
IntegerTypeInteger IntegerType
A constant indicating the datatype number of the datatype Integer.
ListTypeInteger ListType
A constant indicating the datatype number of the datatype List.
ObjectTypeInteger ObjectType
A constant indicating the datatype number of the datatype Object.
ObjRefTypeInteger ObjRefType
A constant indicating the datatype number of the datatype ObjRef.
PointTypeInteger PointType
A constant indicating the datatype number of the datatype Point.
RealTypeInteger RealType
A constant indicating the datatype number of the datatype Real.
ScriptTypeInteger ScriptType
A constant indicating the datatype number of the datatype Script.
StringTypeInteger StringType
A constant indicating the datatype number of the datatype String.
TrueBoolean True
A constant indicating the Boolean value TRUE.
UndefinedUndefined Undefined
A constant indicating the special value Undefined, which is of datatype Undefined.
UndefinedTypeInteger UndefinedType
A constant indicating the datatype number of the datatype Undefined.
VoidTypeInteger VoidType
A constant indicating the datatype number of the datatype void.
DatatypeNameString 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.
typeNumber | - | The datatype number. |
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
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.
firstValue | - | First value to be echoed/logged. |
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.
firstValue | - | First value to be echoed/logged. |
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.
firstValue | - | First value to be echoed/logged. |
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.
firstValue | - | First value to be echoed/logged. |
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.
enable | - | True to enable the timestamp, false to disable. |
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.
firstValue | - | First value to be echoed/logged. |
List GetFeatures( Dynamic firstValue, [Boolean dummy] )
Internal use only.
firstValue | - | First value. |
dummy | - | Unused. |
Boolean IsDefined( Dynamic testValue )
Determines whether a value is not Undefined.
testValue | - | The value to evaluate. |
Note that this will return TRUE for values of type Error.
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.
testValue | - | Value to test. |
compareValue | - | Value to compare. |
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.
object | - | Object-like value |
feature | - | Feature |
This function has a type-specific equivalent function for most datatypes. The following table illustrates these equivalents:
Datatype | Type-specific function. | |
---|---|---|
Assoc | ||
Record | Recarray.IsColumn() | |
ObjRef | OS.IsFeature() | |
Frame | Frame.HasSlot() |
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
Boolean IsInvokable( Dynamic testValue )
Indicates whether the specified value can be invoked. Note that currently, only Script values are invokable.
testValue | - | Value to examine for invokability. |
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.
testValue | - | Value to test |
compareValue | - | Value to compare |
Boolean IsNotSet( Dynamic testValue )
Deprecated. 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.
testValue | - | Value to evaluate |
Boolean IsObject( Dynamic testValue )
Determines whether a value is of datatype Object.
testValue | - | Value to evaluate |
Boolean IsSet( Dynamic testValue )
Deprecated. 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.
testValue | - | Value to evaluate |
Boolean IsUndefined( Dynamic testValue )
Determines whether a value is the special value Undefined.
testValue | - | Value to evaluate. |
Integer Length( Dynamic value )
Returns the length of the specified value.
value | - | Value to return length of. |
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.
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.
whichArg | - | Index (1-based) of desired parameter |
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 Point( Integer hCoord, Integer vCoord )
Deprecated. Construct a Point value from two coordinates. Note that the coordinate values must be between -32768 and +32767.
hCoord | - | The H coordinate |
vCoord | - | The V coordinate |
Integer PointH( Point somePoint )
Deprecated. Return the H coordinate from the specified point.
somePoint | - | Point value from which the H coordinate is to be extracted. |
Integer PointV( Point somePoint )
Deprecated. Return the V coordinate from a Point value.
somePoint | - | Point value from which the V coordinate is to be extracted. |
Integer Type( Dynamic testValue )
Returns the datatype number indicating the type of the given value.
testValue | - | Value for which the corresponding type number is returned. |
Here is an example:
String x echo( Type( x ) ) echo( DatatypeName( Type( x ) ) )
The output from the example is:
-1 String