blindwig Posted June 4, 2005 Share Posted June 4, 2005 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? 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 Link to comment Share on other sites More sharing options...
GaryFrost Posted June 4, 2005 Share Posted June 4, 2005 #80434 SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
blindwig Posted June 7, 2005 Author Share Posted June 7, 2005 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.MWR_Tables.au3 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 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now