GetValue()

Namespace ›› System ›› MfInt64 ›› Methods ››
Parent Previous Next

GetValue()

Overrides MfPrimitive.GetValue().

OutputVar := MfInt64.GetValue(Obj)
OutputVar := MfInt64.GetValue(Obj, Default)
OutputVar := MfInt64.GetValue(Obj, Default, AllowAny)

MfInt64.GetValue(Obj)

Gets the integer number from Object or var containing integer.

Parameters

Obj

The Object or var containing, integer or hex value
Can be any type that matches IsNumber.

Returns

Returns a var containing a integer No less then MinValue and no greater then MaxValue.

Remarks

Static Method
Throws an error if unable to convert Obj to integer.

Throws

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.

MfInt64.GetValue(Obj, Default)

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 an error will be thrown.

Parameters

Obj

The Object or var containing, integer or hex value
Can be any type that matches IsNumber.

Default

The value to return if Obj is Cannot be converted
Can be any type that matches IsNumber or var of integer.

Returns

Returns a var containing a integer or Default value if Obj is unable to be converted to integer.

Remarks

Static Method
If Default is not a valid integer or MfInt64 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 MfInt64.GetValue(Obj).

Throws

Throws MfInvalidOperationException if not called as a static method.

MfInt64.GetValue(Obj, Default, AllowAny)

Gets a integer number from Obj or returns Default value if Obj is unable to be converted to integer.

Parameters

Obj

The Object or var containing, integer or hex value
Can be any type that matches IsNumber.

Default

The value to return if Obj is Cannot be converted
Can be any type that matches IsNumber 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.

Remarks

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 MfInt64.GetValue(Obj, Default).

Throws

Throws MfInvalidOperationException if not called as a static method.
Throws MfArgumentException if AllowAny is not a valid boolean.

General Remarks

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 MfInt64.GetValue(2.8) will be 2 and MfInt64.GetValue(-2.8) will be -2.

Throws MfNotSupportedException if incorrect number of parameters are passed in.

Related

Parse(), TryParse()

Example

Obj := new MfInt64(233)
val := MfInt64.GetValue(Obj)
MsgBox %val% ; displays 233

Obj := new MfInt64(214)
val := MfInt64.GetValue(Obj)
MsgBox %val% ; displays 214

val := MfInt64.GetValue(214)
MsgBox %val% ; displays 214

; the following will throw MfArgumentOutOfRangeException
; MfInt64 can be min of -9223372036854775808 and max of 9223372036854775807
val := MfInt64.GetValue(9223372036854825810.201)
MsgBox %val%

; the following will display zero due to int64 overflow Default is returned
; MfInt64 can be min of -9223372036854775808 and max of 9223372036854775807
val := MfInt64.GetValue(9223372036854825810.201, 0)
MsgBox %val% ; displays 0

flt := new MfFloat(92233720368.8)
val := MfInt64.GetValue(flt)
MsgBox %val% ; displays 92233720368

val := MfInt64.GetValue(0x00F4)
MsgBox %val% ; displays 244

; the following will throw MfArgumentException
val := MfInt64.GetValue("abc")
MsgBox %val%

; the Default set to 25 will be returned
val := MfInt64.GetValue("abc", 25)
MsgBox %val% ; displays 25

VarDefault := new MfInt64(MfInt64.MaxValue)
val := MfInt64.GetValue("abc", VarDefault)
MsgBox %val% ; displays 9223372036854775807

; Default Obj is not a valid integer and Default
; is not a valid integer but AllowAny is true
val := MfInt64.GetValue("abc", "Undefined", true)
MsgBox %val% ; displays Undefined

; MfNumberStyles.Instance.Number is MfEnum.EnumItem
; and MfEnum.EnumItem is of type IsIntegerNumber
val := MfInt64.GetValue(MfNumberStyles.Instance.Number)
MsgBox %val% ; displays 111