I have a function with name GetArrValue(ArrayName, Key) like this!
Code: Select all
Color := {Blue: "0x0000FF", Yellow:"0xFFFF00"}
MsgBox % " Color .: " Color.Yellow
ArrName := "Color"
ArrKey := "Yellow"
MsgBox 64, Row.: %A_LineNumber% -> %A_ScriptName%, % GetArrValue(ArrName, ArrKey)
MsgBox 64, Row.: %A_LineNumber% -> %A_ScriptName%, % GetArrValue("Color", "Green")
GetArrValue(ArrayName, Key)
{ If !IsObject(ArrayName)
{ MsgBox 64, Row.: %A_LineNumber% -> %A_ScriptName%, The Array .: %ArrayName% does not exist. `nThis program is ended!
ExitApp
}
If !%ArrayName%.HasKey(Key)
{ MsgBox 64, Row.: %A_LineNumber% -> %A_ScriptName%, The Key .: %Key% does not exist in the Array .: %ArrayName% `nThis program is ended!
ExitApp
}
Return % %ArrayName%[Key . ""]
}
i.e. If a call to the function, with an array thats not exist, like this .:
Code: Select all
Result := GetArrValue("AllColor","Blue")
My wish is to get this message.: "The Array .: AllColor does not exist..."
Is it possible?