reading a file

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

reading a file

larry
Hello,

Could anyone please explain why the following script does not work?
(It puts into the field the name of the selected file and not the contents of the file.

on mouseUp

answer file "Select a file."

put quote & it & quote into thisFile

open file thisFile

read from file thisFile until EOF

put it into field myOutput

close file thisFile

end mouseUp



Thanks,

Larry
_______________________________________________
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: reading a file

Alain Farmer
replace:
put quote & it & quote into thisFile
with
put it into thisFile


On Sunday, September 21, 2014 6:03 PM, "[hidden email]" <[hidden email]> wrote:
 


Hello,

Could anyone please explain why the following script does not work?
(It puts into the field the name of the selected file and not the contents of the file.

on mouseUp

answer file "Select a file."

put quote & it & quote into thisFile

open file thisFile

read from file thisFile until EOF

put it into field myOutput

close file thisFile

end mouseUp



Thanks,

Larry
_______________________________________________
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
_______________________________________________
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: reading a file

xtalkprogrammer
In reply to this post by larry
Hi,

There is no file quote & it & quote, but there is a file it. Quotes are
used to define a string in a script. If you put quotes in a variable,
they become part of that string. The following script will work:

on mouseUp
   answer file "Select a file."
   put it into thisFile
   open file thisFile
   read from file thisFile until EOF
   put it into field myOutput
   close file thisFile
end mouseUp

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
KvK: 50277553

Installer Maker for LiveCode:
http://qery.us/468

Buy my new book "Programming LiveCode for the Real Beginner"
http://qery.us/3fi

LiveCode on Facebook:
https://www.facebook.com/groups/runrev/

On 9/22/2014 00:02, [hidden email] wrote:

> on mouseUp
>
> answer file "Select a file."
>
> put quote & it & quote into thisFile
>
> open file thisFile
>
> read from file thisFile until EOF
>
> put it into field myOutput
>
> close file thisFile
>
> end mouseUp

_______________________________________________
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
Kind regards,

Drs. Mark Schonewille

Economy-x-Talk Consultancy and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
Facebook: http://facebook.com/LiveCode.Beginner
KvK: 50277553
Reply | Threaded
Open this post in threaded view
|

Re: reading a file

larry
In reply to this post by Alain Farmer
Thanks Alain,

Why is it that if I explicitly want to open a file, I have to put quotes
around the name, but if I put the name in a variable, I do not need the
quotes?
Thank you again,
Larry

----- Original Message -----
From: "Alain Farmer" <[hidden email]>
To: "How to use LiveCode" <[hidden email]>
Sent: Sunday, September 21, 2014 4:09 PM
Subject: Re: reading a file


> replace:
> put quote & it & quote into thisFile
> with
> put it into thisFile
>
>
> On Sunday, September 21, 2014 6:03 PM, "[hidden email]"
> <[hidden email]> wrote:
>
>
>
> Hello,
>
> Could anyone please explain why the following script does not work?
> (It puts into the field the name of the selected file and not the contents
> of the file.
>
> on mouseUp
>
> answer file "Select a file."
>
> put quote & it & quote into thisFile
>
> open file thisFile
>
> read from file thisFile until EOF
>
> put it into field myOutput
>
> close file thisFile
>
> end mouseUp
>
>
>
> Thanks,
>
> Larry
> _______________________________________________
> 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
> _______________________________________________
> 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 


_______________________________________________
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: reading a file

ScottR
In reply to this post by larry
Larry -- have you tried:

  open file thisFile for read


Regards,

Scott Rossi
Creative Director
Tactile Media, UX/UI Design




On 9/21/14 3:02 PM, "[hidden email]"
<[hidden email]> wrote:

>Hello,
>
>Could anyone please explain why the following script does not work?
>(It puts into the field the name of the selected file and not the
>contents of the file.
>
>on mouseUp
>
>answer file "Select a file."
>
>put quote & it & quote into thisFile
>
>open file thisFile
>
>read from file thisFile until EOF
>
>put it into field myOutput
>
>close file thisFile
>
>end mouseUp
>
>
>
>Thanks,
>
>Larry
>_______________________________________________
>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



_______________________________________________
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: reading a file

Alain Farmer
In reply to this post by larry
in reply to: Why is it that if I explicitly want to open a file, I have to put quotes around the name, but if I put the name in a variable, I do not need the quotes?

unquoted names will be interpreted as variables ; with quotes, interpreter knows that it is a literal STRING.
being in a variable is self-delimiting; no need for quotes.



On Sunday, September 21, 2014 6:16 PM, "[hidden email]" <[hidden email]> wrote:
 


Thanks Alain,

Why is it that if I explicitly want to open a file, I have to put quotes
around the name, but if I put the name in a variable, I do not need the
quotes?
Thank you again,
Larry

----- Original Message -----
From: "Alain Farmer" <[hidden email]>
To: "How to use LiveCode" <[hidden email]>
Sent: Sunday, September 21, 2014 4:09 PM
Subject: Re: reading a file


> replace:
> put quote & it & quote into thisFile
> with
> put it into thisFile
>
>
> On Sunday, September 21, 2014 6:03 PM, "[hidden email]"
> <[hidden email]> wrote:
>
>
>
> Hello,
>
> Could anyone please explain why the following script does not work?
> (It puts into the field the name of the selected file and not the contents
> of the file.
>
> on mouseUp
>
> answer file "Select a file."
>
> put quote & it & quote into thisFile
>
> open file thisFile
>
> read from file thisFile until EOF
>
> put it into field myOutput
>
> close file thisFile
>
> end mouseUp
>
>
>
> Thanks,
>
> Larry
> _______________________________________________
> 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
> _______________________________________________
> 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 


_______________________________________________
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
_______________________________________________
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: reading a file

Simon
In reply to this post by Alain Farmer
Hi Larry,
Even shorter
on mouseUp
   answer file "Select a file."
   put url("file:" & it) into fld myOutput
end mouseUp
Of course that is only good for a text file.

Simon