$hmatch » History » Version 3
Per Amundsen, 01/04/2019 09:21 PM
1 | 1 | Per Amundsen | _Added in 2.0_ |
---|---|---|---|
2 | |||
3 | *$hmatch(name|N,text,[N],[M],[@window|command])* |
||
4 | |||
5 | Searches table for the Nth item name which matches text and returns the item name. |
||
6 | |||
7 | 2 | Per Amundsen | Uses [[Scripting_Wildcards|wildcard]] search by default. |
8 | 1 | Per Amundsen | |
9 | 3 | Per Amundsen | _See also [[/hsave]], [[/hload]], [[/hmake]], [[/hfree]], [[/hdel]], [[$hget]]._ |
10 | |||
11 | 1 | Per Amundsen | _See also [[$hfind]]._ |
12 | |||
13 | *Parameters* |
||
14 | |||
15 | name|N - Name of the hash table or the Nth hash table. |
||
16 | text - Text to search for. |
||
17 | [N] - If N = 0, number of matches, otherwise the Nth match. (optional) |
||
18 | [M] - (optional) |
||
19 | <pre> |
||
20 | n - Normal text comparison. (default if M is not specified) |
||
21 | 2 | Per Amundsen | w - Text is [[Scripting_Wildcards|wildcard]] text. |
22 | W - Hash table item/data is [[Scripting_Wildcards|wildcard]] text. |
||
23 | 1 | Per Amundsen | r - Text is a egular expression. |
24 | R - Hash table item/data is a regular expression. |
||
25 | </pre> |
||
26 | |||
27 | [@window|command] - if @window is defined, fills the side-listbox with the results, otherwise the command is run on each result. |
||
28 | |||
29 | *Properties* |
||
30 | |||
31 | .data - Search for a matching data value instead of item name. |
||
32 | |||
33 | *Example* |
||
34 | |||
35 | <pre> |
||
36 | ; Searches hash table 'Example' for all items using and runs the command 'echo -ag $1-' on each result, $1- holds the item name or data. |
||
37 | //echo -ag result: $hmatch(Example, *, 0, w, echo -ag $1-) |
||
38 | |||
39 | ; Searches the hash table 'Example' and prints the number of matches. |
||
40 | //echo -ag result: $hmatch(Example, *, 0, w) |
||
41 | |||
42 | ; Searches the hash table 'Example' and prints the first matched item. |
||
43 | //echo -ag result: $hmatch(Example, *, 1, w) |
||
44 | |||
45 | ; Searches the hash table 'Example' and prints the first matched data. |
||
46 | //echo -ag result: $hmatch(Example, *, 1, w).data |
||
47 | </pre> |