PinkeyNBrain
IS-IT--Management
Does Tcl have a command that will return a variables type anlogous to 'winfo class' ?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
proc parse_info {args} {xxx}
From the first 2 above, I don't have a good way to distinguish between a string or list. However the error from the last console input tells me that somewhere tcl can test between arrays and non-arrays. The 'winfo class' is handy as I can initialize or reset certain vars based on their class. Similar, I am looking to work with the in coming vars based on their type.console input console output
set foo {this is a string} this is a string
string is list $foo 1
set foo [list this is a list] this is a list
string is list $foo 1
set foo(a) {this is arr a} can't set "foo(a)": variable isn't array
# create string
% set my_string "this is my string"
this is my string
# get length of the string
% string length $my_string
20
[COLOR=blue]# get length of list my_string[/color]
% llength $my_string
4
[COLOR=blue]# iterate over the list elements[/color]
% foreach list_element $my_string {
puts $list_element
}
this
is
my
string
%
From a more technical perspective, a list is just a string with a particular syntax. Therefore, in Tcl, a string is either a valid list or not.
....
Tcl, as a general language, does not treat a list differently from other strings. This means it is possible to use lists anywhere one can use arbitrary strings