Instead showing an error, we can define a default value for object, map and array to return when the key / Item / property does not exist.
This is similar to defining a value to aMap.Default:=Value or using aMap.Get(key, DefaultValue) but applies to items and properties.
ObjMapArray := ObjMapArray.DefineDefault([Value])Command Example: ObjMapArray.DefineDefault "" Function Example: ObjMapArray.DefineDefault("")
The name of the variable to store the object, array or map.
The default value (number, string, object, ...) to return when a key / Item / property does not exist.
Leave that parameter empty to restore default behaviour (show an error).
DefaultValue (a string) can also be defined for every object/map/array using #DefineDefaultObjectValue / #DefineDefaultArrayValue / #DefineDefaultMapValue.
For Map and Array the default value will be applied to properties as well.
obj:=[].DefineDefault("Item does not exist!") MsgBox obj[1] ; Item does not exist! obj.DefineDefault '' MsgBox obj[1] ; empty obj.DefineDefault ; restore MsgBox obj[1] ; Error: invalid Index.
Create unsorted Map (applies to items and properties) / Array or Object (applies to properties only).
Normally Integers, Objects and Strings are saved separately and sorted alphabetically for performance. Using UMap/UArray/UObject items and properties will be saved and enumerated in the same order they were added.
map:=UMap("z",1,"a",2,%'99'%,3,%'1'%,4) for k, v in map MsgBox k "=" v
Map() accepts 1 object parameter and uses it for initialization, the object can be either Object, Map or Array.
obj:=Map({z:1,a:2,99:3,1:4}) for k, v in obj MsgBox k "=" v
Default CaseSense for Map.
#MapCaseSense Off obj:=Map() obj["A"]:=1,obj["a"]:=2 MsgBox obj["A"] ; shows 2