The scan Command
The scan command parses a string according to a format specification and assigns values to variables. It returns the number of successful conversions it made. The general form of the command is:
scan string format var ?var? ?var? ...
The format for scan is nearly the same as in the format command. There is no %u scan format. The %c scan format converts one character to its decimal value.
The scan format includes a set notation. Use square brackets to delimit a set of characters. The set matches one or more characters that are copied into the variable. A dash is used to specify a range. The following scans a field of all lowercase letters.
scan abcABC {%[a-z]}result => 1 set result => abc
If the first character in the set ...
Get Practical Programming in Tcl & Tk, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.