Posted to tcl by Whiskey at Mon Feb 19 08:18:57 GMT 2018view raw

  1. proc isTDBC {query} {
  2.  
  3. # Find variables in query
  4. set match [lsearch -all -inline [tdbc::tokenize $query] :*]
  5.  
  6. # Loop found variables
  7. foreach var $match {
  8.  
  9. # Remove the ":" from match
  10. set key [string range $var 1 end]
  11.  
  12. # Import variable
  13. upvar $key $key
  14.  
  15. # Check if dict exist
  16. if {![info exists $key]} {
  17.  
  18. # Throw an error
  19. error "CanĀ“t find variable \"$key\""
  20.  
  21. } else {
  22.  
  23. # Build up dict
  24. dict set dict $key [subst $$key]
  25.  
  26. }
  27. }
  28.  
  29. # Return dict
  30. return $dict
  31. }