$hget » History » Version 8
Per Amundsen, 02/23/2023 01:35 PM
1 | 8 | Per Amundsen | _Added in 1.9.4_ |
---|---|---|---|
2 | |||
3 | *$hash(text, B)* |
||
4 | |||
5 | Returns a hash number based on text where B is the number of bits to use when calculating the hash number. |
||
6 | |||
7 | *Parameters* |
||
8 | 1 | Per Amundsen | _Added in 1.9.0_ |
9 | |||
10 | 8 | Per Amundsen | table(ktable). |
11 | |*Parameter*|*Description*| |
||
12 | 1 | Per Amundsen | *$hget(name|N)* |
13 | |||
14 | 6 | Per Amundsen | Returns name of a hash table if it exists, or returns the name of the Nth hash table. |
15 | |||
16 | 1 | Per Amundsen | _See also [[/hsave]], [[/hload]], [[/hmake]], [[/hfree]], [[/hdel]], [[$hfind]]._ |
17 | |||
18 | *Parameters* |
||
19 | |||
20 | 8 | Per Amundsen | table(ktable). |
21 | |*Parameter*|*Description*| |
||
22 | | name<notextile>|</notextile>N | Name of the hashtable or If N = 0, number of hashtables, otherwise the Nth hashtable name. | |
||
23 | 1 | Per Amundsen | |
24 | *Properties* |
||
25 | |||
26 | 8 | Per Amundsen | table(ktable). |
27 | |*Property*|*Description*| |
||
28 | | .size | Returns the size of the hashtable as specified in [[/hmake]]. | |
||
29 | 1 | Per Amundsen | |
30 | *Example* |
||
31 | |||
32 | <pre> |
||
33 | ; Create a hashtable. |
||
34 | /hmake Example |
||
35 | |||
36 | ; Print number of hashtables. |
||
37 | //echo -ag $hget(0) |
||
38 | |||
39 | ; Print name and size of the first hashtable. |
||
40 | //echo -ag $hget(1) - $hget(1).size |
||
41 | </pre> |
||
42 | |||
43 | ----------------------------------------------------------------------------- |
||
44 | 2 | Per Amundsen | |
45 | 5 | Per Amundsen | *$hget(name|N, item|N, [&binvar])* |
46 | 1 | Per Amundsen | |
47 | Returns the data associated with an item in the specified hash table. |
||
48 | |||
49 | *Parameters* |
||
50 | |||
51 | 8 | Per Amundsen | table(ktable). |
52 | |*Parameter*|*Description*| |
||
53 | | name<notextile>|</notextile>N | Name of the hashtable or the Nth hashtable name. | |
||
54 | | item<notextile>|</notextile>N | Name of the item or if N = 0 number of items, otherwise the Nth item. | |
||
55 | | [&binvar] | Assigns the contents of the item to a &binvar. (optional) | |
||
56 | 1 | Per Amundsen | |
57 | *Properties* |
||
58 | |||
59 | 8 | Per Amundsen | table(ktable). |
60 | |*Property*|*Description*| |
||
61 | | .data | Returns the item value. | |
||
62 | | .item | Returns the item name. | |
||
63 | | .unset | Returns number of seconds before the item is automatically removed (if set). | |
||
64 | | .hash | TODO | |
||
65 | | .state | TODO | |
||
66 | 1 | Per Amundsen | |
67 | *Example* |
||
68 | |||
69 | <pre> |
||
70 | ; Create a hashtable |
||
71 | /hmake Example |
||
72 | |||
73 | ; Add a item to the hashtable |
||
74 | /hadd Example ExampleItem ExampleValue |
||
75 | |||
76 | ; Print number of items in the hastable. |
||
77 | //echo -ag $hget(Example, 0) |
||
78 | |||
79 | ; Print information about the first item in the hashtable. |
||
80 | //echo -ag Name is $hget(Example, 1).item Value is $hget(Example, 1).data Unset at $hget(Example, 1).unset |
||
81 | </pre> |
||
82 | 8 | Per Amundsen | table(ktable). |
83 | |*Parameter*|*Description*| |
||
84 | | text | Text to hash. | |
||
85 | | B | Number of bits to use. (min 2, max 32) | |