The problem is that the eof online is triggered after an unsuccessful
read. I could change my break in a continue, but I do not see that as
an improvement.
Is there a way to get the eof triggered without the unsuccessful read?
On 26/11/2021 14:34, Cecil Westerhof wrote:
The problem is that the eof online is triggered after an unsuccessfulNo. Tcl has no way of knowing it has reached the end of a file until it
read. I could change my break in a continue, but I do not see that as
an improvement.
Is there a way to get the eof triggered without the unsuccessful read?
tries to read past it.
But similar to suggestions in the recent "How to prompt before get?"
thread, you can make a helper proc, or do:
while {[yield; gets $vmstat line] != -1} {
showMessage $line True
}
Or similar to my response to your previous question, use coroutine::util:
while {[coroutine::util gets $vmstat line] != -1} {
showMessage $line True
}
Is there a way to get the eof triggered without the unsuccessful read?
At the moment I have the following code:
while {True} {
yield
if {-1 == [gets ${vmstat} line]} {
break
}
showMessage $line True
}
Instead of True I would prefer to use:
! [eof ${vmstat}]
The problem is that the eof online is triggered after an unsuccessful
read. I could change my break in a continue, but I do not see that as
an improvement.
Is there a way to get the eof triggered without the unsuccessful read?
Am 26.11.2021 um 14:34 schrieb Cecil Westerhof:
At the moment I have the following code:
while {True} {
yield
if {-1 == [gets ${vmstat} line]} {
break
}
showMessage $line True
}
Instead of True I would prefer to use:
! [eof ${vmstat}]
The problem is that the eof online is triggered after an unsuccessful
read. I could change my break in a continue, but I do not see that as
an improvement.
Is there a way to get the eof triggered without the unsuccessful read?
Dear Cecil,
it is not necessarily an unsuccessful read. Only a read instruction
updates the eof indicator. If there appears eof in the read, it is
updated. It must not be "unsuccessful" (means with empty result).
Sorry for the details,
Schelte <nos...@wanadoo.nl> writes:
On 26/11/2021 14:34, Cecil Westerhof wrote:
The problem is that the eof online is triggered after an unsuccessfulNo. Tcl has no way of knowing it has reached the end of a file until it tries to read past it.
read. I could change my break in a continue, but I do not see that as
an improvement.
Is there a way to get the eof triggered without the unsuccessful read?
But similar to suggestions in the recent "How to prompt before get?" thread, you can make a helper proc, or do:
while {[yield; gets $vmstat line] != -1} {
showMessage $line True
}
Or similar to my response to your previous question, use coroutine::util:
while {[coroutine::util gets $vmstat line] != -1} {I like the last one. I will implement that one.
showMessage $line True
}
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 285 |
Nodes: | 16 (2 / 14) |
Uptime: | 76:00:38 |
Calls: | 6,489 |
Calls today: | 2 |
Files: | 12,096 |
Messages: | 5,276,210 |