Please enable JavaScript to view this site.

A-Shell Development History

Ordered map—aka associative array—enhancement: support for binary (X type) elements. Previously the elements could only be string type, making it difficult to handle elements with multiple parts—i.e. a structure. Syntax:

dimx $smap, ordmap(varstr;varstr)   ! (old) string key, string data

dimx $xmap, ordmap(varstr;varx)     ! (new) string key, unformatted data

Once declared the usage syntax for the two variations of map is the same, except that you must use the new .ISNULL(var) method of testing for a non-existent element, as the old method of comparing against the system variable .NULL will not work for the X type elements or variables.

As with ordered maps containing string elements, the unformatted (X type) elements are dynamically sized and thus may be of different length for each element. However, it is probably most useful for storing structures in ordered maps, which is directly analogous to an index file totally in memory. For example:

defstruct ST_FOO

    map2 key,s,10

    map2 f1,f

    ...

endstruct

 

map1 foo, ST_FOO                  ! instance of structure

 

dimx $fooary, ordmap(varstr;varx) ! map of structures

...

$fooary(foo.key) = foo            ! load map directly from structure foo

...

foo = $fooary(key)                ! read from map into structure

? foo.key, foo.f1, ...            ! access the structure members