Object features

DefineDefault()

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("")
OutputVar

The name of the variable to store the object, array or map.

Value

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).

Remarks

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.

Examples

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.

UMap() / UArray() / UObject()

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.

Examples

map:=UMap("z",1,"a",2,%'99'%,3,%'1'%,4)
for k, v in map
  MsgBox k "=" v

MapFromObject

Map() accepts 1 object parameter and uses it for initialization, the object can be either Object, Map or Array.

Examples

obj:=Map({z:1,a:2,99:3,1:4})
for k, v in obj
  MsgBox k "=" v

#MapCaseSense On | Off | Locale

Default CaseSense for Map.

Examples

#MapCaseSense Off
obj:=Map()
obj["A"]:=1,obj["a"]:=2
MsgBox obj["A"] ; shows 2