Page 1 of 1

.

Posted: Thu Jan 08, 2015 4:39 pm
by MCKALISTAIR
I'm a complete livecode begginer so the solution is probably something incredibly simple. What i'm trying to do is read some text from a text file on my desktop (MacBook Pro running Yosemite) into a text field by pressing a button. I have included a screenshot with some code i've been trying, the card I've been working from and you can see on the right hand side the "mydata.txt but nothing has been working and no errors have been showing up when I test.


Here is some of the code I have been trying

Code: Select all

 
on mouseUp
   //put url "MacintoshHD/Users/Alistair/Desktop/mydata.txt" into field "test"
   //put URL specialFolderPath("desktop") & /myData.txt into field "test"
   put url "/Macintosh_HD/Users/Alistair/Desktop/myData.txt" into variable
   put variable into field "test"
end mouseUp
Any help is greatly appreciated

Alistair

Re: Could someone give me a hand with a file reading issue?

Posted: Thu Jan 08, 2015 4:43 pm
by dunbarx
HI.

As a new member here (you need a dozen or so posts) you cannot attach files to your queries. But have you read the "read from file" command in the dictionary? This would be what you need. Practice just a bit, make sure your file paths are correct (or get them from the "answer file" command).

You can post the script you are using as text in the body of the post, if you want to take that route.

Craig Newman

Re: Could someone give me a hand with a file reading issue?

Posted: Thu Jan 08, 2015 4:50 pm
by FourthWorld
More useful than a screenshot is the code. Use the Code tag available in the post editor here, and once we see what you're currently using we'll be able to advise on how to improve it.

Re: Could someone give me a hand with a file reading issue?

Posted: Thu Jan 08, 2015 5:05 pm
by Dixie
Alistair...

Attached a stack that will should you how to get hold of the text in your file...:-)

Re: Could someone give me a hand with a file reading issue?

Posted: Thu Jan 08, 2015 6:01 pm
by Klaus
Hi Alistair,

please have a deep look at (some of) these stacks to get the basics of Liveocde:
http://www.hyperactivesw.com/revscriptc ... ences.html


Best

Klaus