Arie
Apr 27, 2008Altostratus
Syntax for arrays?
Apparently arrays are more efficient than Data Lists (matchclass), but I am unable to find the syntax to set the array (and populate it) and how to use it for a matchclass-equivalent.
array set ::Connexiondata { } Here the name of our array will be connection data
insert data:
set ::Connexiondata($myUserID) $uri Here we insert our data ($uri) in our data through the index $myuserid
find data:
if {[info exists ::Connexiondata($myUserID)]} { Here we check if we have some data for the index $myuserid
set user_data $::Connexiondata($myUserID) Here we retrieve the data based on the index
}
Check all data:
foreach { data } [array names ::Connexiondata] { on this loop we will extract all data inserted in Connexion data and assign it to $data
}
Remove data:
unset ::Connexiondata($index) Here we remove the data that are linked to the index $index
One piece of warning, You don't have any kind of timeout with array so you need to be careful how much data you handle since you are limited to 4Mb.
Usually it is possible to do the same thing with the session command which contains some timeout information.
HTH