$hget » History » Version 6
Per Amundsen, 01/04/2019 09:20 PM
1 | 1 | Per Amundsen | _Added in 1.9.0_ |
---|---|---|---|
2 | |||
3 | *$hget(name|N)* |
||
4 | |||
5 | Returns name of a hash table if it exists, or returns the name of the Nth hash table. |
||
6 | |||
7 | 6 | Per Amundsen | _See also [[/hsave]], [[/hload]], [[/hmake]], [[/hfree]], [[/hdel]], [[$hfind]]._ |
8 | |||
9 | 1 | Per Amundsen | *Parameters* |
10 | |||
11 | name|N - Name of the hashtable or If N = 0, number of hashtables, otherwise the Nth hashtable name. |
||
12 | |||
13 | *Properties* |
||
14 | |||
15 | 3 | Per Amundsen | .size - Returns the size of the hashtable as specified in [[/hmake]]. |
16 | 1 | Per Amundsen | |
17 | *Example* |
||
18 | |||
19 | <pre> |
||
20 | ; Create a hashtable. |
||
21 | /hmake Example |
||
22 | |||
23 | ; Print number of hashtables. |
||
24 | //echo -ag $hget(0) |
||
25 | |||
26 | ; Print name and size of the first hashtable. |
||
27 | //echo -ag $hget(1) - $hget(1).size |
||
28 | </pre> |
||
29 | |||
30 | ----------------------------------------------------------------------------- |
||
31 | |||
32 | *$hget(name|N, item|N, [&binvar])* |
||
33 | |||
34 | Returns the data associated with an item in the specified hash table. |
||
35 | |||
36 | *Parameters* |
||
37 | |||
38 | name|N - Name of the hashtable or the Nth hashtable name. |
||
39 | 2 | Per Amundsen | item|N - Name of the item or if N = 0 number of items, otherwise the Nth item. |
40 | 5 | Per Amundsen | [&binvar] - Assigns the contents of the item to a &binvar. (optional) |
41 | 1 | Per Amundsen | |
42 | *Properties* |
||
43 | |||
44 | .data - Returns the item value. |
||
45 | .item - Returns the item name. |
||
46 | 4 | Per Amundsen | .unset - Returns number of seconds before the item is automatically removed (if set). |
47 | 1 | Per Amundsen | |
48 | *Example* |
||
49 | |||
50 | <pre> |
||
51 | ; Create a hashtable |
||
52 | /hmake Example |
||
53 | |||
54 | ; Add a item to the hashtable |
||
55 | /hadd Example ExampleItem ExampleValue |
||
56 | |||
57 | ; Print number of items in the hastable. |
||
58 | //echo -ag $hget(Example, 0) |
||
59 | |||
60 | ; Print information about the first item in the hashtable. |
||
61 | //echo -ag Name is $hget(Example, 1).item Value is $hget(Example, 1).data Unset at $hget(Example, 1).unset |
||
62 | </pre> |