just for fun: pop quiz

Richard Gaskin ambassador at fourthworld.com
Sun Feb 3 14:08:45 EST 2013


Jerry Jensen wrote:

 >>> On 03/02/2013, at 11:36 AM, Richard Gaskin wrote:
 >>>
 >>>> Without looking in the Dictionary, what would you expect the value
 >>>> of tResult to be after successful execution of:
 >>>>
 >>>> open file tValidFilePath for read
 >>>> read from file tValidFilePath until EOF
 >>>> put the result into tResult
 >>>> close file tValidFilePath
 >>>>
 >>>>
 >> On 03/02/2013, at 11:38 AM, Monte Goulding wrote:
 >>
 >>> empty?
 >>>
 > On Feb 2, 2013, at 4:39 PM, Monte Goulding wrote:
 >
 >> :-(
 >>
 > Me too. ;-(
 >

Curious, isn't it?

In my informal survey among people I've talked with the results were the 
same as here, with nearly everyone guessing that a read command which 
executes without error would have empty in "the result".

Instead, in the case of using specifically "...until EOF" or "...until 
end", the result contains "eof".

This turns out to be documented (down in the fine print toward the 
bottom of the Dictionary entry for "read from file", but not above in 
the section that describes what "EOF" does), yet it's such a departure 
from the rest of the language that I was tempted to flag it as a bug.

It's been around so long that they're not likely to change it, so I 
won't be littering the RQCC with yet another unactionable request.

Still, does seem odd.

Can you think of a circumstance in which you've already specified to 
read until EOF, and the command executes flawlessly just as you've asked 
it to, yet you still need to be notified that it reached EOF?

--
  Richard Gaskin
  Fourth World
  LiveCode training and consulting: http://www.fourthworld.com
  Webzine for LiveCode developers: http://www.LiveCodeJournal.com
  Follow me on Twitter:  http://twitter.com/FourthWorldSys




More information about the use-livecode mailing list