Overrides MfPrimitive.GetValue().
OutputVar := MfInteger.GetValue(Obj)
OutputVar := MfInteger.GetValue(Obj, Default)
OutputVar := MfInteger.GetValue(Obj, Default, AllowAny)
Gets the integer number from Object or var containing integer.
Obj
The Object or var containing, integer or hex value
Can be any type that matches IsNumber.
Returns a var containing a integer No less then MinValue and no greater then MaxValue.
Static Method
Throws an error if unable to convert Obj to integer.
Throws MfInvalidOperationException if not called as a static method.
Throws MfArgumentOutOfRangeException if Obj is less then MinValue or Greater then MaxValue.
Throws MfArgumentException if argument Obj is can not be converted to integer value.
Gets a integer number from Obj or returns Default value if Obj is unable to be converted to integer. Default must be a value that can be converted to integer or it will be ignored if Obj can not be converted to integer and an error will be thrown.
Obj
The Object or var containing, integer or hex value
Can be any type that matches IsIntegerNumber.
Default
The value to return if Obj is Cannot be converted
Can be any type that matches IsIntegerNumber or var of integer.
Returns a var containing a integer or Default value if Obj is unable to be converted to integer.
Static Method
If Default is not a valid integer or MfInteger instance then GetValue will throw an error if Obj can not be converted to integer.
If Default can not be converted to a integer then this would method will yield the same results as calling MfInteger.GetValue(Obj).
Throws MfInvalidOperationException if not called as a static method.
Gets a integer number from Obj or returns Default value if Obj is unable to be converted to integer.
Obj
The Object or var containing, integer or hex value
Can be any type that matches IsIntegerNumber.
Default
The value to return if Obj is Cannot be converted
Can be any type that matches IsIntegerNumber or var of integer.
AlowAny
Determines if Default can be a value other then integer. If true Default can be any var, Object or null; Otherwise Default must be a integer value.
Static Method.
If AllowAny is true then Default can be any value including var, object or null. However if AllowAny is false then this method will yield the same result as calling MfInteger.GetValue(Obj, Default).
Throws MfInvalidOperationException if not called as a static method.
Throws MfArgumentException if AllowAny is not a valid boolean.
If Obj is a float or MfFloat instance then GetValue() will alway round down for positive number and round up for negative numbers. For instance MfInteger.GetValue(2.8) will be 2 and MfInteger.GetValue(-2.8) will be -2.
Throws MfNotSupportedException if incorrect number of parameters are passed in.
Obj := new MfInt64(233)
val := MfInteger.GetValue(Obj)
MsgBox %val% ; displays 233
Obj := new MfInteger(214)
val := MfInteger.GetValue(Obj)
MsgBox %val% ; displays 214
val := MfInteger.GetValue(214)
MsgBox %val% ; displays 214
; the following will throw MfArgumentException
; MfInteger can be min of -2147483647 and max of 2147483647
val := MfInteger.GetValue(0x80000008) ; 0x80000008 = 2147483656
MsgBox %val%
; the following will display zero due to integer overflow Default is returned
; MfInteger can be min of -2147483647 and max of 2147483647
val := MfInteger.GetValue(0x80000008, 0) ; 0x80000008 = 2147483656
MsgBox %val% ; displays 0
; the following will throw MfArgumentException
; MfInteger can be min of -2147483647 and max of 2147483647
; Default value passed in is not a valid integer
val := MfInteger.GetValue(0x80000008, -3147483656) ; 0x80000008 = 2147483656
MsgBox %val%
; the following will display -2147483649 due to integer overflow Default is returned
; Default value passed in is not a valid Int32 but will return anyways
; because AllowAny is Set to true
val := MfInteger.GetValue(2147483656, -2147483649, true)
MsgBox %val% ; displays -2147483649
val := MfInteger.GetValue(0x00F4)
MsgBox %val% ; displays 244
; the following will throw MfArgumentException
val := MfInteger.GetValue("abc")
MsgBox %val%
; the Default set to 25 will be returned
val := MfInteger.GetValue("abc", 25)
MsgBox %val% ; displays 25
VarDefault := new MfInteger(MfInteger.MaxValue)
val := MfInteger.GetValue("abc", VarDefault)
MsgBox %val% ; displays 2147483647
; Default Obj is not a valid integer and Default
; is not a valid integer but AllowAny is true
val := MfInteger.GetValue("abc", "Undefined", true)
MsgBox %val% ; displays Undefined
; MfNumberStyles.Instance.Number is MfEnum.EnumItem
; and MfEnum.EnumItem is of type IsIntegerNumber
val := MfInteger.GetValue(MfNumberStyles.Instance.Number)
MsgBox %val% ; displays 111