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

proc isTDBC {query} {

  # Find variables in query
  set match [lsearch -all -inline [tdbc::tokenize $query] :*]

  # Loop found variables
  foreach var $match {

    # Remove the ":" from match
    set key [string range $var 1 end]

    # Import variable
    upvar $key $key

    # Check if dict exist
    if {![info exists $key]} {

      # Throw an error
      error "CanĀ“t find variable \"$key\""

    } else {
    
      # Build up dict
      dict set dict $key [subst $$key]
        
    }
  }

  # Return dict
  return $dict
}