mIRC Home    About    Download    Register    News    Help

Print Thread
#268958 21/05/21 05:26 PM
Joined: Apr 2010
Posts: 969
F
Hoopy frood
OP Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
Does anyone know the exact format used when saving a hashtable to file?

The reason I ask is I would like to write an output from a COM to file for mIRC to load and manipulate


I am SReject
My Stuff
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
The default format is simply a text file where the odd lines are the itemnames and the even lines are their text data, with lines ending with $crlf. If there's an odd number of lines, it's ignoring that last line.

I'm assuming you don't want to mess with creating the file in .ini format, where additional complicated rules apply, including ;comments.

If the format is going to be &binary, that will be 1 of 2 different formats, depending on whether it's -b or -B, with -b supporting length only up to 65535. The itemnames are case-insensitive only as far as a-zA-Z, since the next example creates 26 items fewer than 65535 items:

//hfree -w test | var %i 1 | while (%i isnum 1-65535) { hadd -m test $+(item,$chr(%i)) 1 | inc %i } | echo -a $hget(test,0).item

It allows creating itemnames that can't be created from the /hadd command, and which can't be deleted due to containing a space:, unless you use a wildcard which has the potential of deleting extra items.

//write -c test.hsh item name | write test.hsh data | hfree -w test | hload -m test test.hsh | hdel -s test $hget(test,1).item | echo -a $hget(test,1).item

For -b binary format it's little-endian:

uint16 length of itemname in bytes
itemname itself
uint16 length of data
data itself

For -B binary it's the same except for the length fields being uint32's

Joined: Apr 2010
Posts: 969
F
Hoopy frood
OP Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
Originally Posted by maroon
uint16/32 - length of itemn in bytes
itemname
uint16/32 - length of data
data

The info I was looking for. thank you


I am SReject
My Stuff

Link Copied to Clipboard