From WikiChip
Editing mirc/commands/hsave
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
This page supports semantic in-text annotations (e.g. "[[Is specified as::World Heritage Site]]") to build structured and queryable content provided by Semantic MediaWiki. For a comprehensive description on how to use annotations or the #ask parser function, please have a look at the getting started, in-text annotation, or inline queries help pages.
Latest revision | Your text | ||
Line 3: | Line 3: | ||
== Synopsis == | == Synopsis == | ||
− | /hsave - | + | /hsave -bnusa <name> <filename> |
/hsave -inusa <name> <filename> [section] | /hsave -inusa <name> <filename> [section] | ||
Line 15: | Line 15: | ||
* '''-a''' - appends to an existing file instead of overwriting it | * '''-a''' - appends to an existing file instead of overwriting it | ||
'''Note:''' versions.txt change log for v5.8 shows /hsave having a -o switch to overwrite the disk file. However this was long ago deprecated without versions.txt being updated. At least as far back as v6.35, /hsave overwrites the contents of the disk file without the need to use the -o switch. If you do use -o, it is silently ignored, as mIRC often does with invalid switches. | '''Note:''' versions.txt change log for v5.8 shows /hsave having a -o switch to overwrite the disk file. However this was long ago deprecated without versions.txt being updated. At least as far back as v6.35, /hsave overwrites the contents of the disk file without the need to use the -o switch. If you do use -o, it is silently ignored, as mIRC often does with invalid switches. | ||
− | |||
− | |||
== Parameters == | == Parameters == | ||
Line 25: | Line 23: | ||
<source lang="mIRC"> | <source lang="mIRC"> | ||
* If using -a switch to append to an existing file, you should also use -b, -n, or -i [section] switches if those were used to create the original file, to avoid mixing formats with undesirable results. | * If using -a switch to append to an existing file, you should also use -b, -n, or -i [section] switches if those were used to create the original file, to avoid mixing formats with undesirable results. | ||
− | * If saving using -b | + | * If saving using -b or -i or -n switches to save the hash table to disk, you should generally use those same switches again with /hload if you plan to reload the hash table from disk back into memory. |
− | |||
Disk structure of saved file: | Disk structure of saved file: | ||
− | |||
* Disk Structure: Default with no switch: | * Disk Structure: Default with no switch: | ||
− | + | Each item saved as a pair of text lines, with the first line being the name of the item, and the next line being the value. (Or a blank line if the item has $null value). If saving 20 items to disk, the file has 40 lines, with the item names on the odd-numbered lines and their values being the even numbered lines which follow the line containing the name of the item. | |
* Disk Structure: -n switch | * Disk Structure: -n switch | ||
− | + | Item names not written to disk, only the data values written to disk. If saving 20 items to disk, the 20 data values are written to 20 lines, without the item names written to disk. If you /hload this file with the -n switch, the table creates item names numbered as the sequential integers beginning with 1, containing the data on disk. The Nth line of the disk file is loaded as the data for item name using the number N. If -n is used along with the -i switch, the items are written to disk in the .ini format with assigned itemnames, such as writing lines like n0=value n1=value etc. | |
* Disk Structure: -b switch | * Disk Structure: -b switch | ||
Items saved to disk in binary format: | Items saved to disk in binary format: | ||
− | + | 2 bytes containing the length of the following item name in bigendian format. These bytes are 0x08 0x00 for an 8-character item name | |
− | + | The text name of the item. If the first 2 bytes were 0x08 0x00, the following 8 bytes are the name of the item. | |
− | + | 2 bytes containing the length of the following data value. These bytes are 0x05 0x00 when there is a 5 byte value following these 2 bytes. The value is the number of bytes not the $len of the data. Data value tést is UTF-8 encoded as 5 bytes even though the $len() is 4. | |
− | + | The bytes of the data value. There is no $crlf written to disk unless the value is a binary variable containing the $chr(13) $chr(10) bytes. | |
− | + | Repeat the above until the end of file is reached. | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
* Disk Structure: -i switch with optional [section] | * Disk Structure: -i switch with optional [section] | ||
Line 94: | Line 62: | ||
//hfree -w test | hadd -m test itemA 12345 | hinc -z test itemB 67890 | hadd -u30 test itemC value3 | hsave -u test test.dat | var %i 1 , %tot $lines(test.dat) | while (%i <= %tot) { echo -a line %i is $read(test.dat,nt,%i) | inc %i } | //hfree -w test | hadd -m test itemA 12345 | hinc -z test itemB 67890 | hadd -u30 test itemC value3 | hsave -u test test.dat | var %i 1 , %tot $lines(test.dat) | while (%i <= %tot) { echo -a line %i is $read(test.dat,nt,%i) | inc %i } | ||
* The disk file contains 6 lines (3 pairs) for the 3 items because hsave used the -u switch. If the -u switch is deleted, the 2nd and 3rd item are not written to disk because they have a non-zero property for $hget(table-name,item-name).unset | * The disk file contains 6 lines (3 pairs) for the 3 items because hsave used the -u switch. If the -u switch is deleted, the 2nd and 3rd item are not written to disk because they have a non-zero property for $hget(table-name,item-name).unset | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</source> | </source> | ||
== Compatibility == | == Compatibility == | ||
{{mIRC compatibility|5.8}} | {{mIRC compatibility|5.8}} | ||
== See also == | == See also == | ||
+ | {{collist | ||
+ | |count = 3 | ||
+ | |style = width: 60%; display: inherit; | ||
+ | | | ||
* {{mIRC|/hmake}} | * {{mIRC|/hmake}} | ||
* {{mIRC|/hfree}} | * {{mIRC|/hfree}} | ||
Line 128: | Line 80: | ||
* {{mIRC|$hget}} | * {{mIRC|$hget}} | ||
* {{mIRC|$hfind}} | * {{mIRC|$hfind}} | ||
+ | }} |