4glworks offers a homegrown implementation of associative arrays built
over memory located byte variables. Hashes have no limit in the number of
entries and are self reorganizing.
K_entrysize and K_defsize (see the declarations
below) are currently set to 32K.
The functions below that return values return nulls in case of erroneous
arguments. All set status in case of errors.
| file | chstc.c |
| declaration |
function hst_drop(ht, e)
define ht byte,
e char(K_entrysize)
|
| returns | nothing |
| purpose | Deletes an entry from an associative array. |
| example | none |
| notes | none |
| file | chstc.c |
| declaration |
function hst_enter(ht, e, d)
define ht byte,
e char(K_entrysize),
d char(K_defsize)
|
| returns | nothing |
| purpose | Adds or updates an entry to an associative array. |
| example | none |
| notes | none |
| file | chstc.c |
| declaration |
function hst_enterdate(ht, e, d)
define ht byte,
e char(K_entrysize),
d date
|
| returns | nothing |
| purpose | Adds or updates an entry to an associative array. |
| example | none |
| notes | none |
| file | chstc.c |
| declaration |
function hst_enterdecimal(ht, e, d)
define ht byte,
e char(K_entrysize),
d decimal
|
| returns | nothing |
| purpose | Adds or updates an entry to an associative array. |
| example | none |
| notes | none |
| file | chstc.c |
| declaration |
function hst_enterdtime(ht, e, d)
define ht byte,
e char(K_entrysize),
d datetime
|
| returns | nothing |
| purpose | Adds or updates an entry to an associative array. |
| example | none |
| notes | none |
| file | chstc.c |
| declaration |
function hst_enterfloat(ht, e, d)
define ht byte,
e char(K_entrysize),
d float
|
| returns | nothing |
| purpose | Adds or updates an entry to an associative array. |
| example | none |
| notes | none |
| file | chstc.c |
| declaration |
function hst_enterint(ht, e, d)
define ht byte,
e char(K_entrysize),
d integer
|
| returns | nothing |
| purpose | Adds or updates an entry to an associative array. |
| example | none |
| notes | none |
| file | chstc.c |
| declaration |
function hst_enterinv(ht, e, d)
define ht byte,
e char(K_entrysize),
d interval
|
| returns | nothing |
| purpose | Adds or updates an entry to an associative array. |
| example | none |
| notes | none |
| file | chstc.c |
| declaration |
function hst_free(ht)
define ht byte
|
| returns | nothing |
| purpose | Frees a hash variable |
| example | none |
| notes |
It appears that 4gl keeps track of the blobs it locates, so while it is
entirely possible to free hashes the 4gl way, this is
cumbersome and error prone. Use hst_free instead.
|
| file | chstc.c |
| declaration |
function hst_member(ht, e)
define ht byte,
e char(K_entrysize)
|
| returns | m, boolean |
| purpose | Tests whether an entry is member of an associative array. |
| example | none |
| notes | none |
| file | chstc.c |
| declaration |
function hst_retrieve(ht, e)
define ht byte,
e char(K_entrysize)
|
| returns |
d, char(K_entrysize), value associated with entry e
|
| purpose | Retrieves the value associated with an entry of an associative array. |
| example | none |
| notes | in actual fact, hst_retrieve return value could
be of any type. It is safer to use a character destination variable if the
type of the return value of hst_retrieve is not readily
available |
| file | chstc.c |
| declaration |
function hst_scan(ht, idx)
define ht byte,
idx integer
|
| returns |
e, char(K_entrysize), next entry d, char(K_entrysize), entry value idx, integer, routine state. |
| purpose | Scans an associative array. |
| example | none |
| notes |
|
| file | chstc.c |
| declaration |
function hst_start(ht, hs)
define ht byte,
hs smallint
|
| returns | nothing |
| purpose | Initializes an associative array. |
| example | none |
| notes |
|