Utilities
Overview
Utilities is the class to use to convert values to other types, get argument values and do other things based on the rules defined in the Javascript specification. All functions here follow the rules exactly and are used by the runtime when dealing with the scripts.
Location
- Reference: RemObjects.Script.dll
- Namespace: RemObjects.Script.EcmaScript
fEncoding
class var fEncoding: Encoding;
static Encoding fEncoding
Shared FIELD fEncoding() As Encoding
GetArg
Returns an argument by index, returns Undefined.Instance when the index is out of range.
class method GetArg(arg: array of Object; index: Int32): Object
static Object GetArg(Object[] arg, Int32 index)
Shared Function GetArg(arg As Object(), index As Int32) As Object
Parameters:
- arg: argument list
- index: zero based index
GetArgAsBoolean
Returns an argument by index and converts it to a boolean. If the value cannot be converted, the default is false.
class method GetArgAsBoolean(arg: array of Object; index: Int32; ec: ExecutionContext): Boolean
static Boolean GetArgAsBoolean(Object[] arg, Int32 index, ExecutionContext ec)
Shared Function GetArgAsBoolean(arg As Object(), index As Int32, ec As ExecutionContext) As Boolean
Parameters:
- arg: argument list
- index: zero based index
- ec: current execution context, defines the conversion rules and scope
GetArgAsDouble
Returns an argument by index and converts it to a double. If the value cannot be converted, the default is 0, or infinity for undefined.
class method GetArgAsDouble(arg: array of Object; index: Int32; ec: ExecutionContext): Double
static Double GetArgAsDouble(Object[] arg, Int32 index, ExecutionContext ec)
Shared Function GetArgAsDouble(arg As Object(), index As Int32, ec As ExecutionContext) As Double
Parameters:
- arg: argument list
- index: zero based index
- ec: current execution context, defines the conversion rules and scope
GetArgAsEcmaScriptObject
Returns an argument by index and converts it to an EcmAScriptObject. If the value cannot be converted, the default is nil.
class method GetArgAsEcmaScriptObject(arg: array of Object; index: Int32; ec: ExecutionContext): EcmaScriptObject
static EcmaScriptObject GetArgAsEcmaScriptObject(Object[] arg, Int32 index, ExecutionContext ec)
Shared Function GetArgAsEcmaScriptObject(arg As Object(), index As Int32, ec As ExecutionContext) As EcmaScriptObject
Parameters:
- arg: argument list
- index: zero based index
- ec: current execution context, defines the conversion rules and scope
GetArgAsInt64
Returns an argument by index and converts it to an Int64. If the value cannot be converted, the default is 0.
class method GetArgAsInt64(arg: array of Object; index: Int32; ec: ExecutionContext): Int64
static Int64 GetArgAsInt64(Object[] arg, Int32 index, ExecutionContext ec)
Shared Function GetArgAsInt64(arg As Object(), index As Int32, ec As ExecutionContext) As Int64
Parameters:
- arg: argument list
- index: zero based index
- ec: current execution context, defines the conversion rules and scope
GetArgAsInteger
Returns an argument by index and converts it to an Integer. If the value cannot be converted, the default is 0.
class method GetArgAsInteger(arg: array of Object; index: Int32; ec: ExecutionContext; aTreatInfinity: Boolean): Int32
static Int32 GetArgAsInteger(Object[] arg, Int32 index, ExecutionContext ec, Boolean aTreatInfinity)
Shared Function GetArgAsInteger(arg As Object(), index As Int32, ec As ExecutionContext, aTreatInfinity As Boolean) As Int32
Parameters:
- arg: argument list
- index: zero based index
- ec: current execution context, defines the conversion rules and scope
- aTreatInfinity: If true, returns Int32.MinValue or Int32.MaxValue for neg/pos infinity
GetArgAsString
Returns an argument by index and converts it to a String. If the value cannot be converted, the default is 0.
class method GetArgAsString(arg: array of Object; index: Int32; ec: ExecutionContext): String
static String GetArgAsString(Object[] arg, Int32 index, ExecutionContext ec)
Shared Function GetArgAsString(arg As Object(), index As Int32, ec As ExecutionContext) As String
Parameters:
- arg: argument list
- index: zero based index
- ec: current execution context, defines the conversion rules and scope
GetObjAsBoolean
Converts an object to boolean, defaults to false if not possible. Calls toString and valueOf if the value is an EcmaScriptObject.
class method GetObjAsBoolean(arg: Object; ec: ExecutionContext): Boolean
static Boolean GetObjAsBoolean(Object arg, ExecutionContext ec)
Shared Function GetObjAsBoolean(arg As Object, ec As ExecutionContext) As Boolean
Parameters:
- arg: value
- ec: execution context (scope)
GetObjAsCardinal
Converts an object to a Cardinal value, defaults to 0if not possible. Calls toString and valueOf if the value is an EcmaScriptObject.
class method GetObjAsCardinal(arg: Object; ec: ExecutionContext): UInt32
static UInt32 GetObjAsCardinal(Object arg, ExecutionContext ec)
Shared Function GetObjAsCardinal(arg As Object, ec As ExecutionContext) As UInt32
Parameters:
- arg: value
- ec: execution context (scope)
GetObjAsDouble
Converts an object to a double value, defaults to 0 or infinity if not possible. Calls toString and valueOf if the value is an EcmaScriptObject.
class method GetObjAsDouble(arg: Object; ec: ExecutionContext): Double
static Double GetObjAsDouble(Object arg, ExecutionContext ec)
Shared Function GetObjAsDouble(arg As Object, ec As ExecutionContext) As Double
Parameters:
- arg: value
- ec: execution context (scope)
GetObjAsEcmaScriptObject
Returns the EcmaScriptObject value of the object passed, if possible, else nil.
class method GetObjAsEcmaScriptObject(arg: Object; ec: ExecutionContext): EcmaScriptObject
static EcmaScriptObject GetObjAsEcmaScriptObject(Object arg, ExecutionContext ec)
Shared Function GetObjAsEcmaScriptObject(arg As Object, ec As ExecutionContext) As EcmaScriptObject
Parameters:
- arg: value
- ec: execution context (scope)
GetObjAsInt64
Converts the value passed to an Int64, or 0 if not possible.
class method GetObjAsInt64(arg: Object; ec: ExecutionContext): Int64
static Int64 GetObjAsInt64(Object arg, ExecutionContext ec)
Shared Function GetObjAsInt64(arg As Object, ec As ExecutionContext) As Int64
Parameters:
- arg: value
- ec: execution context (scope)
GetObjAsInteger
Converts the value passed to an Integer, or 0 if not possible.
class method GetObjAsInteger(arg: Object; ec: ExecutionContext; aTreatInfinity: Boolean): Int32
static Int32 GetObjAsInteger(Object arg, ExecutionContext ec, Boolean aTreatInfinity)
Shared Function GetObjAsInteger(arg As Object, ec As ExecutionContext, aTreatInfinity As Boolean) As Int32
Parameters:
- arg: value
- ec: scope
- aTreatInfinity: If true, returns min/max int32 value for infinity, else 0.
GetObjAsString
Returns the string value of an object. This calls toString/valueOf if the value passed is an EcmaScriptObject, else returns the string representation of the value.
class method GetObjAsString(arg: Object; ec: ExecutionContext): String
static String GetObjAsString(Object arg, ExecutionContext ec)
Shared Function GetObjAsString(arg As Object, ec As ExecutionContext) As String
Parameters:
- arg: input value
- ec: current scope
GetObjectAsPrimitive
Return the primitive value of an Object. This unwraps any value, if they're wrapped, the result type is always one of nil, undefined, Int32, Int64, Double or String.
class method GetObjectAsPrimitive(ec: ExecutionContext; arg: EcmaScriptObject; aPrimitive: PrimitiveType): Object
static Object GetObjectAsPrimitive(ExecutionContext ec, EcmaScriptObject arg, PrimitiveType aPrimitive)
Shared Function GetObjectAsPrimitive(ec As ExecutionContext, arg As EcmaScriptObject, aPrimitive As PrimitiveType) As Object
Parameters:
- ec: scope
- arg: value
- aPrimitive: preferred conversion, if string, it prefers to convert a value to a string, else if it's number, to a double. If "None" it returns whatever is in there.
IsCallable
Is callable returns if the value in o can be invoked as a function.
class method IsCallable(o: Object): Boolean
static Boolean IsCallable(Object o)
Shared Function IsCallable(o As Object) As Boolean
Parameters:
- o: the value to check
IsPrimitive
Returns true if the passed value is a primitive (undefined, null, int, double, int64 or string)
class method IsPrimitive(arg: Object): Boolean
static Boolean IsPrimitive(Object arg)
Shared Function IsPrimitive(arg As Object) As Boolean
Parameters:
- arg: the value to check
method_GetObjAsBoolean
class var method_GetObjAsBoolean: MethodInfo;
static MethodInfo method_GetObjAsBoolean
Shared FIELD method_GetObjAsBoolean() As MethodInfo
Method_GetObjAsString
class var Method_GetObjAsString: MethodInfo;
static MethodInfo Method_GetObjAsString
Shared FIELD Method_GetObjAsString() As MethodInfo
ParseDouble
Parses a double according to the number parsing rules defined by the Javascript spec.
class method ParseDouble(s: String; allowHex: Boolean): Double
static Double ParseDouble(String s, Boolean allowHex)
Shared Function ParseDouble(s As String, allowHex As Boolean) As Double
Parameters:
- s: input
- allowHex: allow hex input
ToObject
Returns (if the value already is an EcmaScriptObject) or wraps a primitive in an object. Fails on null and undefined.
class method ToObject(ec: ExecutionContext; o: Object): EcmaScriptObject
static EcmaScriptObject ToObject(ExecutionContext ec, Object o)
Shared Function ToObject(ec As ExecutionContext, o As Object) As EcmaScriptObject
Parameters:
- ec: scope
- o: input value
UrlDecode
Url decode method, part of the core library.
class method UrlDecode(s: String; aComponent: Boolean): String
static String UrlDecode(String s, Boolean aComponent)
Shared Function UrlDecode(s As String, aComponent As Boolean) As String
Parameters:
- s: input value
- aComponent: If true follows the rules for url components, else for full urls.
UrlEncode
Url encoding a string.
class method UrlEncode(s: String): String
static String UrlEncode(String s)
Shared Function UrlEncode(s As String) As String
Parameters:
- s: input
UrlEncodeComponent
Encode a url component to a string.
class method UrlEncodeComponent(s: String): String
static String UrlEncodeComponent(String s)
Shared Function UrlEncodeComponent(s As String) As String
Parameters:
- s: Input value.
fEncoding
class var fEncoding: Encoding;
static Encoding fEncoding
Shared FIELD fEncoding() As Encoding
method_GetObjAsBoolean
class var method_GetObjAsBoolean: MethodInfo;
static MethodInfo method_GetObjAsBoolean
Shared FIELD method_GetObjAsBoolean() As MethodInfo
Method_GetObjAsString
class var Method_GetObjAsString: MethodInfo;
static MethodInfo Method_GetObjAsString
Shared FIELD Method_GetObjAsString() As MethodInfo
GetArg
Returns an argument by index, returns Undefined.Instance when the index is out of range.
class method GetArg(arg: array of Object; index: Int32): Object
static Object GetArg(Object[] arg, Int32 index)
Shared Function GetArg(arg As Object(), index As Int32) As Object
Parameters:
- arg: argument list
- index: zero based index
GetArgAsBoolean
Returns an argument by index and converts it to a boolean. If the value cannot be converted, the default is false.
class method GetArgAsBoolean(arg: array of Object; index: Int32; ec: ExecutionContext): Boolean
static Boolean GetArgAsBoolean(Object[] arg, Int32 index, ExecutionContext ec)
Shared Function GetArgAsBoolean(arg As Object(), index As Int32, ec As ExecutionContext) As Boolean
Parameters:
- arg: argument list
- index: zero based index
- ec: current execution context, defines the conversion rules and scope
GetArgAsDouble
Returns an argument by index and converts it to a double. If the value cannot be converted, the default is 0, or infinity for undefined.
class method GetArgAsDouble(arg: array of Object; index: Int32; ec: ExecutionContext): Double
static Double GetArgAsDouble(Object[] arg, Int32 index, ExecutionContext ec)
Shared Function GetArgAsDouble(arg As Object(), index As Int32, ec As ExecutionContext) As Double
Parameters:
- arg: argument list
- index: zero based index
- ec: current execution context, defines the conversion rules and scope
GetArgAsEcmaScriptObject
Returns an argument by index and converts it to an EcmAScriptObject. If the value cannot be converted, the default is nil.
class method GetArgAsEcmaScriptObject(arg: array of Object; index: Int32; ec: ExecutionContext): EcmaScriptObject
static EcmaScriptObject GetArgAsEcmaScriptObject(Object[] arg, Int32 index, ExecutionContext ec)
Shared Function GetArgAsEcmaScriptObject(arg As Object(), index As Int32, ec As ExecutionContext) As EcmaScriptObject
Parameters:
- arg: argument list
- index: zero based index
- ec: current execution context, defines the conversion rules and scope
GetArgAsInt64
Returns an argument by index and converts it to an Int64. If the value cannot be converted, the default is 0.
class method GetArgAsInt64(arg: array of Object; index: Int32; ec: ExecutionContext): Int64
static Int64 GetArgAsInt64(Object[] arg, Int32 index, ExecutionContext ec)
Shared Function GetArgAsInt64(arg As Object(), index As Int32, ec As ExecutionContext) As Int64
Parameters:
- arg: argument list
- index: zero based index
- ec: current execution context, defines the conversion rules and scope
GetArgAsInteger
Returns an argument by index and converts it to an Integer. If the value cannot be converted, the default is 0.
class method GetArgAsInteger(arg: array of Object; index: Int32; ec: ExecutionContext; aTreatInfinity: Boolean): Int32
static Int32 GetArgAsInteger(Object[] arg, Int32 index, ExecutionContext ec, Boolean aTreatInfinity)
Shared Function GetArgAsInteger(arg As Object(), index As Int32, ec As ExecutionContext, aTreatInfinity As Boolean) As Int32
Parameters:
- arg: argument list
- index: zero based index
- ec: current execution context, defines the conversion rules and scope
- aTreatInfinity: If true, returns Int32.MinValue or Int32.MaxValue for neg/pos infinity
GetArgAsString
Returns an argument by index and converts it to a String. If the value cannot be converted, the default is 0.
class method GetArgAsString(arg: array of Object; index: Int32; ec: ExecutionContext): String
static String GetArgAsString(Object[] arg, Int32 index, ExecutionContext ec)
Shared Function GetArgAsString(arg As Object(), index As Int32, ec As ExecutionContext) As String
Parameters:
- arg: argument list
- index: zero based index
- ec: current execution context, defines the conversion rules and scope
GetObjAsBoolean
Converts an object to boolean, defaults to false if not possible. Calls toString and valueOf if the value is an EcmaScriptObject.
class method GetObjAsBoolean(arg: Object; ec: ExecutionContext): Boolean
static Boolean GetObjAsBoolean(Object arg, ExecutionContext ec)
Shared Function GetObjAsBoolean(arg As Object, ec As ExecutionContext) As Boolean
Parameters:
- arg: value
- ec: execution context (scope)
GetObjAsCardinal
Converts an object to a Cardinal value, defaults to 0if not possible. Calls toString and valueOf if the value is an EcmaScriptObject.
class method GetObjAsCardinal(arg: Object; ec: ExecutionContext): UInt32
static UInt32 GetObjAsCardinal(Object arg, ExecutionContext ec)
Shared Function GetObjAsCardinal(arg As Object, ec As ExecutionContext) As UInt32
Parameters:
- arg: value
- ec: execution context (scope)
GetObjAsDouble
Converts an object to a double value, defaults to 0 or infinity if not possible. Calls toString and valueOf if the value is an EcmaScriptObject.
class method GetObjAsDouble(arg: Object; ec: ExecutionContext): Double
static Double GetObjAsDouble(Object arg, ExecutionContext ec)
Shared Function GetObjAsDouble(arg As Object, ec As ExecutionContext) As Double
Parameters:
- arg: value
- ec: execution context (scope)
GetObjAsEcmaScriptObject
Returns the EcmaScriptObject value of the object passed, if possible, else nil.
class method GetObjAsEcmaScriptObject(arg: Object; ec: ExecutionContext): EcmaScriptObject
static EcmaScriptObject GetObjAsEcmaScriptObject(Object arg, ExecutionContext ec)
Shared Function GetObjAsEcmaScriptObject(arg As Object, ec As ExecutionContext) As EcmaScriptObject
Parameters:
- arg: value
- ec: execution context (scope)
GetObjAsInt64
Converts the value passed to an Int64, or 0 if not possible.
class method GetObjAsInt64(arg: Object; ec: ExecutionContext): Int64
static Int64 GetObjAsInt64(Object arg, ExecutionContext ec)
Shared Function GetObjAsInt64(arg As Object, ec As ExecutionContext) As Int64
Parameters:
- arg: value
- ec: execution context (scope)
GetObjAsInteger
Converts the value passed to an Integer, or 0 if not possible.
class method GetObjAsInteger(arg: Object; ec: ExecutionContext; aTreatInfinity: Boolean): Int32
static Int32 GetObjAsInteger(Object arg, ExecutionContext ec, Boolean aTreatInfinity)
Shared Function GetObjAsInteger(arg As Object, ec As ExecutionContext, aTreatInfinity As Boolean) As Int32
Parameters:
- arg: value
- ec: scope
- aTreatInfinity: If true, returns min/max int32 value for infinity, else 0.
GetObjAsString
Returns the string value of an object. This calls toString/valueOf if the value passed is an EcmaScriptObject, else returns the string representation of the value.
class method GetObjAsString(arg: Object; ec: ExecutionContext): String
static String GetObjAsString(Object arg, ExecutionContext ec)
Shared Function GetObjAsString(arg As Object, ec As ExecutionContext) As String
Parameters:
- arg: input value
- ec: current scope
GetObjectAsPrimitive
Return the primitive value of an Object. This unwraps any value, if they're wrapped, the result type is always one of nil, undefined, Int32, Int64, Double or String.
class method GetObjectAsPrimitive(ec: ExecutionContext; arg: EcmaScriptObject; aPrimitive: PrimitiveType): Object
static Object GetObjectAsPrimitive(ExecutionContext ec, EcmaScriptObject arg, PrimitiveType aPrimitive)
Shared Function GetObjectAsPrimitive(ec As ExecutionContext, arg As EcmaScriptObject, aPrimitive As PrimitiveType) As Object
Parameters:
- ec: scope
- arg: value
- aPrimitive: preferred conversion, if string, it prefers to convert a value to a string, else if it's number, to a double. If "None" it returns whatever is in there.
IsCallable
Is callable returns if the value in o can be invoked as a function.
class method IsCallable(o: Object): Boolean
static Boolean IsCallable(Object o)
Shared Function IsCallable(o As Object) As Boolean
Parameters:
- o: the value to check
IsPrimitive
Returns true if the passed value is a primitive (undefined, null, int, double, int64 or string)
class method IsPrimitive(arg: Object): Boolean
static Boolean IsPrimitive(Object arg)
Shared Function IsPrimitive(arg As Object) As Boolean
Parameters:
- arg: the value to check
ParseDouble
Parses a double according to the number parsing rules defined by the Javascript spec.
class method ParseDouble(s: String; allowHex: Boolean): Double
static Double ParseDouble(String s, Boolean allowHex)
Shared Function ParseDouble(s As String, allowHex As Boolean) As Double
Parameters:
- s: input
- allowHex: allow hex input
ToObject
Returns (if the value already is an EcmaScriptObject) or wraps a primitive in an object. Fails on null and undefined.
class method ToObject(ec: ExecutionContext; o: Object): EcmaScriptObject
static EcmaScriptObject ToObject(ExecutionContext ec, Object o)
Shared Function ToObject(ec As ExecutionContext, o As Object) As EcmaScriptObject
Parameters:
- ec: scope
- o: input value
UrlDecode
Url decode method, part of the core library.
class method UrlDecode(s: String; aComponent: Boolean): String
static String UrlDecode(String s, Boolean aComponent)
Shared Function UrlDecode(s As String, aComponent As Boolean) As String
Parameters:
- s: input value
- aComponent: If true follows the rules for url components, else for full urls.
UrlEncode
Url encoding a string.
class method UrlEncode(s: String): String
static String UrlEncode(String s)
Shared Function UrlEncode(s As String) As String
Parameters:
- s: input
UrlEncodeComponent
Encode a url component to a string.
class method UrlEncodeComponent(s: String): String
static String UrlEncodeComponent(String s)
Shared Function UrlEncodeComponent(s As String) As String
Parameters:
- s: Input value.