OutputVar := MfNull.IsNull(obj)
Get if the obj parameter is null or MfNull.
obj
The object to check or var to check
Returns true if obj is null or is MfNull.
Throws MfInvalidOperationException if not called as a static method.
Static Method:
If obj is "" (null value) then true is returned.
If parameter obj is instance of MfChar and has a MfChar.CharCode that equal zero then it will be considered as null.
If parameter obj is instance of MfString and MfString.Length is equal to zero then it will be consider as null.
It is import to call base New when creating new classes or MfNull.IsNull will return true even if your class creates an instance.
; MfChar Instances and MfNull.IsNull()
ch1 := new MfChar("0x0000")
ch2 := new MfChar("")
ch3 := new MfChar()
ch4 := new MfChar(" ") ; char is a space
ch5 := new MfChar(0) ; char is latin1 zero - CharCode of 0x0030
strResult := new MfString()
OutputVar := MfNull.IsNull(ch1) ; returns true
AppendResult(OutputVar, strResult)
OutputVar := MfNull.IsNull(ch2) ; returns true
AppendResult(OutputVar, strResult)
OutputVar := MfNull.IsNull(ch3) ; returns true
AppendResult(OutputVar, strResult)
OutputVar := MfNull.IsNull(ch4) ; returns false
AppendResult(OutputVar, strResult)
OutputVar := MfNull.IsNull(ch5) ; returns false
AppendResult(OutputVar, strResult)
MsgBox % strResult.Value
; strResult.Value contains
/* True
* True
* True
* False
* False
*/
; MfString Instances and MfNull.IsNull()
str1 := new MfString() ; empty string
str2 := new MfString("")
str3 := new MfString(MfString.Empty)
str4 := new MfString(" ") ; str4.Value is a space
; reset strResult
strResult.Value := MfString.Empty
OutputVar := MfNull.IsNull(str1) ; returns true
AppendResult(OutputVar, strResult)
OutputVar := MfNull.IsNull(str2) ; returns true
AppendResult(OutputVar, strResult)
OutputVar := MfNull.IsNull(str3) ; returns true
AppendResult(OutputVar, strResult)
OutputVar := MfNull.IsNull(str4) ; returns false
AppendResult(OutputVar, strResult)
OutputVar := MfNull.IsNull(MfString.Empty) ; return true
AppendResult(OutputVar, strResult)
MsgBox % strResult.Value
; strResult.Value contains
/* True
* True
* True
* False
* True
*/
; other objects and vars
o := ""
p := MfNull.Null
q := MfNull.Null.Value
r := Object()
s := MfInteger ; non instance of MfInteger
t := new MfInteger(10)
u := 10
v := "abc"
w := 0
x := "0"
; reset strResult
strResult.Value := MfString.Empty
OutputVar := MfNull.IsNull(o) ; returns true
AppendResult(OutputVar, strResult)
OutputVar := MfNull.IsNull(p) ; returns true
AppendResult(OutputVar, strResult)
OutputVar := MfNull.IsNull(q) ; returns true
AppendResult(OutputVar, strResult)
OutputVar := MfNull.IsNull(r) ; returns false
AppendResult(OutputVar, strResult)
OutputVar := MfNull.IsNull(s) ; returns true
AppendResult(OutputVar, strResult)
OutputVar := MfNull.IsNull(t) ; returns false
AppendResult(OutputVar, strResult)
OutputVar := MfNull.IsNull(u) ; returns false
AppendResult(OutputVar, strResult)
OutputVar := MfNull.IsNull(v) ; returns false
AppendResult(OutputVar, strResult)
OutputVar := MfNull.IsNull(w) ; returns false
AppendResult(OutputVar, strResult)
OutputVar := MfNull.IsNull(x) ; returns false
AppendResult(OutputVar, strResult)
MsgBox % strResult.Value
; strResult.Value contains
/* True
* True
* True
* False
* False
* False
* False
* False
* False
* False
*/
ExitApp
AppendResult(result, byref strObj) {
if (result) {
strObj.AppendLine("True")
} else {
strObj.AppendLine("False")
}
}