From WikiChip
Difference between revisions of "mirc/commands/hload"
m (Bot: de-linking old mIRC menu) |
m (Correct typo.) |
||
(6 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{mirc title|/hload Command}} | {{mirc title|/hload Command}} | ||
− | The '''/ | + | The '''/hload''' command loads a text file to an hash table. /hload does not create the table, it must already have been created by {{mIRC|/hmake}} then saved to disk using {{mIRC|/hsave}}. |
− | |||
== Synopsis == | == Synopsis == | ||
− | /hload - | + | /hload -sBbnmN <name> <filename> |
+ | /hload -sinmN <name> <filename> [section] | ||
== Switches == | == Switches == | ||
− | |||
− | |||
− | |||
* '''-s''' - display a message if successful: "* Loaded hash table '<name>' from '<filename>' | * '''-s''' - display a message if successful: "* Loaded hash table '<name>' from '<filename>' | ||
+ | * '''-b''' - loads binary files, {{mIRC|$cr}} and {{mIRC|$lf}} and 0x00's etc are preserved when saving as binary files | ||
+ | * '''-B''' - uses a larger index than -b to allow longer binary data to be saved. This is not compatible with files created by the -b switch. | ||
+ | * '''-n''' - loads files as data only, each item is a sequential integer, starting at N = 1 | ||
+ | * '''-i''' - treats the file as an ini file format | ||
+ | * '''-mN''' - create the hash table if it does not exist, you can optionally specify N for the number of buckets in the range 1-10000, default 100 if N not used. | ||
== Parameters == | == Parameters == | ||
* '''<name>''' - the name of the hash table | * '''<name>''' - the name of the hash table | ||
− | * '''<filename>''' - the file you want to load | + | * '''<filename>''' - the file from which you want to load. Filename containing space much be enclosed in doublequotes. |
− | * '''[section]''' - if -i is used, you can specify a section to be loaded | + | * '''[section]''' - if -i is used, you can specify a section to be loaded. Default section name when parameter not used: hashtable (Should not use the square braces around the Section name.) |
+ | == Notes == | ||
+ | * Note: /hload uses the same syntax as /hsave except /hload has the -mN switch but does not have /hsave's -u switch. | ||
+ | * Note: If using /hload -i or -b or -n switches, it assumes the data was /hsave'ed to disk using those same switches. | ||
+ | * Note: If /hload into a table containing existing items, any match between existing item name and the items loaded from disk replaces the existing item's value with the value from disk, but any other existing items in the table are not affected by an /hload command. | ||
+ | == Example == | ||
+ | <source lang="mIRC"> | ||
+ | //hfree -w test | hload -im1n test $nopath($mircini) colors | var %tot $hget(test,0).item , %i 1 | while (%i <= %tot) { echo -a $ord(%i) item is $hget(test,%i).item containing $hget(test,$hget(test,%i).item) | inc %i } | ||
+ | * Loads color scheme names and event colors into items named after the integers 1 and greater. These are contained in the colors section of mirc.ini. If the 'n' switch were not used, the item names would instead be named the same as the items in mirc.ini; n0 n1 etc. | ||
+ | * If using the -n switch, do not expect the same values to be loaded into the same integer item names from which they were /hsave'ed to disk, even if using 1 bucket. | ||
− | + | //hload -m test no_such_file | echo -a does not display | |
− | + | * Attempting to load a non-existent filename is an error which halts execution of the script. | |
+ | //bset &var 1 $regsubex($str(x,256),/x/gi,$calc(\n -1) $chr(32)) | hfree -w test | hadd -mb test ascii &var | hsave -b test test.dat | hload -mb test2 test.dat | noop $hget(test,ascii,©) | echo 4 -a $bvar(©,1-) | ||
+ | * Binary variable can be accurately saved to a hashtable item, then /hsave'ed to disk with the -b switch, then /hload'ed from disk with the -b switch. The display shows © containing an un-altered copy of the original binary variable. | ||
+ | </source> | ||
== Compatibility == | == Compatibility == | ||
Added: 5.8 | Added: 5.8 | ||
− | |||
== See also == | == See also == | ||
− | * | + | * {{mIRC|/hmake}} |
− | * | + | * {{mIRC|/hfree}} |
+ | * {{mIRC|/hsave}} | ||
+ | * {{mIRC|Hash Tables}} | ||
+ | * {{mIRC|/hadd}} | ||
+ | * {{mIRC|/hdel}} | ||
+ | * {{mIRC|/hinc}} | ||
+ | * {{mIRC|/hdec}} | ||
* {{mIRC|$hget}} | * {{mIRC|$hget}} | ||
* {{mIRC|$hfind}} | * {{mIRC|$hfind}} | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Latest revision as of 04:32, 19 January 2024
Commands & Identifiers
Basics
Events
Matching Tools
Data Storage
Control Structures
GUI Scripting
Sockets
Advanced Scripting
Additional Resources
Security
Other
The /hload command loads a text file to an hash table. /hload does not create the table, it must already have been created by /hmake then saved to disk using /hsave.
Synopsis[edit]
/hload -sBbnmN <name> <filename> /hload -sinmN <name> <filename> [section]
Switches[edit]
- -s - display a message if successful: "* Loaded hash table '<name>' from '<filename>'
- -b - loads binary files, $cr and $lf and 0x00's etc are preserved when saving as binary files
- -B - uses a larger index than -b to allow longer binary data to be saved. This is not compatible with files created by the -b switch.
- -n - loads files as data only, each item is a sequential integer, starting at N = 1
- -i - treats the file as an ini file format
- -mN - create the hash table if it does not exist, you can optionally specify N for the number of buckets in the range 1-10000, default 100 if N not used.
Parameters[edit]
- <name> - the name of the hash table
- <filename> - the file from which you want to load. Filename containing space much be enclosed in doublequotes.
- [section] - if -i is used, you can specify a section to be loaded. Default section name when parameter not used: hashtable (Should not use the square braces around the Section name.)
Notes[edit]
- Note: /hload uses the same syntax as /hsave except /hload has the -mN switch but does not have /hsave's -u switch.
- Note: If using /hload -i or -b or -n switches, it assumes the data was /hsave'ed to disk using those same switches.
- Note: If /hload into a table containing existing items, any match between existing item name and the items loaded from disk replaces the existing item's value with the value from disk, but any other existing items in the table are not affected by an /hload command.
Example[edit]
//hfree -w test | hload -im1n test $nopath($mircini) colors | var %tot $hget(test,0).item , %i 1 | while (%i <= %tot) { echo -a $ord(%i) item is $hget(test,%i).item containing $hget(test,$hget(test,%i).item) | inc %i } * Loads color scheme names and event colors into items named after the integers 1 and greater. These are contained in the colors section of mirc.ini. If the 'n' switch were not used, the item names would instead be named the same as the items in mirc.ini; n0 n1 etc. * If using the -n switch, do not expect the same values to be loaded into the same integer item names from which they were /hsave'ed to disk, even if using 1 bucket. //hload -m test no_such_file | echo -a does not display * Attempting to load a non-existent filename is an error which halts execution of the script. //bset &var 1 $regsubex($str(x,256),/x/gi,$calc(\n -1) $chr(32)) | hfree -w test | hadd -mb test ascii &var | hsave -b test test.dat | hload -mb test2 test.dat | noop $hget(test,ascii,©) | echo 4 -a $bvar(©,1-) * Binary variable can be accurately saved to a hashtable item, then /hsave'ed to disk with the -b switch, then /hload'ed from disk with the -b switch. The display shows © containing an un-altered copy of the original binary variable.
Compatibility[edit]
Added: 5.8