what does the return value of gets command in following exercise means?
I tried to read file by tclsh on command line.
File
10 2 12 1 13
1 2 3 4 5 6
1 2 3 4 5
1 2 3 4a 5
Command & Output (command-line)
% set fp [open file r]
file4
% gets $fp line
45
% gets $fp line
42
% gets $fp line
41
% gets $fp line
42
% gets $fp line
-1
% close $fp
when I got -1 output I closed the file-pointer $fp. but what does the values 45 42 41 42 meant?
Quoting from the man page of
getscommandAs you can see from the man page, it returns the count of characters which is read by
getscommand in one single line. In the first line of the file, it read 45 characters and returned 45 as a result and the string value will be stored in the variablelineas per your code.This is repeated for all lines and will return -1 once the
eofreached for that file.