UUIDs (Universally Unique Identifier) or GUIDs (Globally Unique Identifier) are defined in this document: [http://www.webdav.org/specs/draft-leach-uuids-guids-01.txt] ---- [PT] 8-Jul-2004: I have just added a UUID module to [tcllib] that implements type 4 uuids from the draft specification document. eg: % package require uuid 1.0.0 % set id [uuid::uuid generate] 140d7c2c-4502-4144-6ae0-a4692e8ed819 % if {[uuid::uuid equal $id $id]} { puts "ids equal" } ---- Windows provides an API for generating GUIDs and some extensions make use of this, but I needed a pure-[Tcl] UUID generator. So, I came up with this. This proc, by no means, conforms to the standards discussed in the above document, but it does produce unique identifiers that are good enough for me. :) [Damon Courtney] proc uuid {} { ## Try and get a string unique to this host. set str [info hostname]$::tcl_platform(machine)$::tcl_platform(os) binary scan $str h* hex set uuid [format %2.2x [clock seconds]] append uuid -[string range [format %2.2x [clock clicks]] 0 3] append uuid -[string range [format %2.2x [clock clicks]] 2 5] append uuid -[string range [format %2.2x [clock clicks]] 4 end] append uuid -[string range $hex 0 11] return $uuid } proc guid {} { ## Return a GUID for Windows, which is just an uppercase UUID with brackets. return \{[string toupper [uuid]]\} } ---- [Scott Nichols] I wrote a Windows C based Tcl extension for this ([TclGetGUID]) a few months back, and Pat helped by recommending the use of the Tcl C API call Tcl_UtfToUpper for converting a string to uppercase. The C source is really short and simple. It simply calls some underlying Windows APIs. ---- [DKF]: Don't forget to include planet and stellar system identifiers in that UUID... :^D ---- [Category Glossary] | [Category Package] distributed as a module in [Tcllib]