An anomaly in the "read from file" command?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

An anomaly in the "read from file" command?

Mike Kerner via use-livecode
First off, thanks to Alan Stenhouse for zeroing in on my filter-related mistake. Any number fo people *could* have done so, but it was Alan who actually did the deed. So, yay Alan!

Second: I discovered something odd as a result of another mistake I made. My mistake:

ask file "What do you want to read?"
put it into DisFile
read from file DisFile until EOF
put it into fld "This Field"

What went into field "This Field" was the contents of the *variable* DisFile, *not* the contents of the *file* whose name is stored in the variable DisFile. This is because of how the pseudo-variable "it" behaves, i suspect.

My mistake was that I didn't *open* file DisFile before reading it, of course. And once I did open the file, the reading went on normally, and the contents of the field did indeed end up in the field "This Field". So, bad on me for not opening the file first, good on me for recognizing & fixing that lapse without external assistance. But I do have a question:

Why didn't I get an error message when I tried to read from a file that hadn't been opened yet? Shouldn't LiveCode have gotten fussy about that?

   
"Bewitched" + "Charlie's Angels" - Charlie = "At Arm's Length"
   
Read the webcomic at [ http://www.atarmslength.net ]!
   
If you like "At Arm's Length", support it at [ http://www.patreon.com/DarkwingDude ].

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: An anomaly in the "read from file" command?

Mike Kerner via use-livecode
On 2017-04-26 08:35, Quentin Long via use-livecode wrote:
> ask file "What do you want to read?"
> put it into DisFile
> read from file DisFile until EOF
> put it into fld "This Field"
>
> Why didn't I get an error message when I tried to read from a file
> that hadn't been opened yet? Shouldn't LiveCode have gotten fussy
> about that?

The read / write file commands both set 'the result' if there is an
error with the operation requested - in this case it would be set to
something like 'file not open'.

Warmest Regards,

Mark.

--
Mark Waddingham ~ [hidden email] ~ http://www.livecode.com/
LiveCode: Everyone can create apps

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode