This should be easy ...
I'm reading a line from a text file, then I'm scanning the line with a format string to two variables. When I go to display the 2nd variable, it says "Can't read var2: no such variable".
what am I doing wrong within the scan cmd?
EXAMPLE
somefile.txt file contains:
abc xyz
excerpt of code:
1> set FID [open somefile.txt r]
2> gets $FID line
3> scan $line "%3s, %3s" var1 var2
4> .logwindow insert end "$var1 $var2"
{note: "logwindow" is the item_name of a text widget}
Via the scan, how do I write to the 2nd variable?
Note: the following lines give me ...
> .logwindow insert end [llength $line] gives me 2", which is what I expect.
> .logwindow insert end [scan $line "%3s, %3s" var1 var2] gives me "1". WHY ONLY ONE CONVERSION ????
IF the reason is whitspace in my text file, even when I modify the text file to "xyzabc", I still would expect to have two conversions to both var1 and var2 in the scan function.
I'm reading a line from a text file, then I'm scanning the line with a format string to two variables. When I go to display the 2nd variable, it says "Can't read var2: no such variable".
what am I doing wrong within the scan cmd?
EXAMPLE
somefile.txt file contains:
abc xyz
excerpt of code:
1> set FID [open somefile.txt r]
2> gets $FID line
3> scan $line "%3s, %3s" var1 var2
4> .logwindow insert end "$var1 $var2"
{note: "logwindow" is the item_name of a text widget}
Via the scan, how do I write to the 2nd variable?
Note: the following lines give me ...
> .logwindow insert end [llength $line] gives me 2", which is what I expect.
> .logwindow insert end [scan $line "%3s, %3s" var1 var2] gives me "1". WHY ONLY ONE CONVERSION ????
IF the reason is whitspace in my text file, even when I modify the text file to "xyzabc", I still would expect to have two conversions to both var1 and var2 in the scan function.