I'm wroking on writing a small UDF library for a variable type that I call "Tables". These are called other things by other people - dictionaries, maps, hashes, etc
A table is a 2-dimensional array, where the 2nd dimension is normally 2.
the value at [0][0] is a number telling the number of rows in the table.
The values at [x][0] are the keys (unique) and the values at [x][1] are the values associated with these keys.
An example of this is what is returned by the IniReadSection function.
I'm writing a UDF library to create a table, add key/value entrie(s), and to retrieve a value based on a key.
Has anyone else done something like this, or is there a set of functions to do this already out there somewhere? Any comments?
UDF - Tables Library - RFC
Started by
blindwig
, Jun 04 2005 12:11 AM
2 replies to this topic
#1
Posted 04 June 2005 - 12:11 AM
My UDF Threads:Pseudo-Hash: Binary Trees, Flat TablesFiles: Filter by Attribute, Tree List, Recursive Find, Recursive Folders Size, exported to XMLArrays: Nested, Pull Common Elements, Display 2dSystem: Expand Environment Strings, List Drives, List USB DrivesMisc: Multi-Layer Progress Bars, Binary FlagsStrings: Find Char(s) in String, Find String in SetOther UDF Threads I Participated:Base64 Conversions
#2
Posted 04 June 2005 - 12:18 AM
SciTE for AutoItDirections for Submitting Standard UDFs
Don't argue with an idiot; people watching may not be able to tell the difference.
#3
Posted 07 June 2005 - 12:21 AM
Well, I'll post my functions here, if anyone wants them:
And here's the headers, since there isn't much documentation in the file itself (it's still a work in progress) I think they're pretty self-explainatory, but here goes:
$_TableDefaultLength=20
;A table is created at default length if a length is not given
$_TableDefaultIncrease=20
;If a table has no room for another key, then it will be increased by this size.
Func _TableCreate(ByRef $Table, $Length = -1, $Width = 2)
;This will create a new table in $Table
Func _TableIsValid($Table)
;This will verify that $Table is a valid table, and will return true/false
Func _TableSetValue(ByRef $Table, $Key, $Value)
;This will set $Key in $Table to $Value. If $Key doesn't exist, it is added
Func _TableGetIndex($Table, $Key)
;This will return the index in $Table where $Key resides. Do not save this value, as it could change if the table is compressed, sorted, or otherwise optimized.
Func _TableGetValue($Table, $Key, $Column=1, $Default='')
;Returns the value of $Key in $Table. Returns $Default if non-existant. $Key is case-insensative
Func _TablePrint($Table, $Delim=',', $EOL=@CRLF)
;This is a method for displaying $Table in ASCII mode. $Delim will be between columns, and $EOL will be added to the end of each line except the last one.
Func _TableGetKeys($Table)
;This will return an array of the keys in $Table. [0]=x and [1]..[x] are the keys.
And here's the headers, since there isn't much documentation in the file itself (it's still a work in progress) I think they're pretty self-explainatory, but here goes:
$_TableDefaultLength=20
;A table is created at default length if a length is not given
$_TableDefaultIncrease=20
;If a table has no room for another key, then it will be increased by this size.
Func _TableCreate(ByRef $Table, $Length = -1, $Width = 2)
;This will create a new table in $Table
Func _TableIsValid($Table)
;This will verify that $Table is a valid table, and will return true/false
Func _TableSetValue(ByRef $Table, $Key, $Value)
;This will set $Key in $Table to $Value. If $Key doesn't exist, it is added
Func _TableGetIndex($Table, $Key)
;This will return the index in $Table where $Key resides. Do not save this value, as it could change if the table is compressed, sorted, or otherwise optimized.
Func _TableGetValue($Table, $Key, $Column=1, $Default='')
;Returns the value of $Key in $Table. Returns $Default if non-existant. $Key is case-insensative
Func _TablePrint($Table, $Delim=',', $EOL=@CRLF)
;This is a method for displaying $Table in ASCII mode. $Delim will be between columns, and $EOL will be added to the end of each line except the last one.
Func _TableGetKeys($Table)
;This will return an array of the keys in $Table. [0]=x and [1]..[x] are the keys.
Attached Files
My UDF Threads:Pseudo-Hash: Binary Trees, Flat TablesFiles: Filter by Attribute, Tree List, Recursive Find, Recursive Folders Size, exported to XMLArrays: Nested, Pull Common Elements, Display 2dSystem: Expand Environment Strings, List Drives, List USB DrivesMisc: Multi-Layer Progress Bars, Binary FlagsStrings: Find Char(s) in String, Find String in SetOther UDF Threads I Participated:Base64 Conversions
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users






