.

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
MCKALISTAIR
Posts: 4
Joined: Wed Dec 17, 2014 8:03 pm

.

Post by MCKALISTAIR » Thu Jan 08, 2015 4:39 pm

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
Last edited by MCKALISTAIR on Sun Mar 08, 2015 2:39 pm, edited 2 times in total.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

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

Post by dunbarx » Thu Jan 08, 2015 4:43 pm

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

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

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

Post by FourthWorld » Thu Jan 08, 2015 4:50 pm

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.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

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

Post by Dixie » Thu Jan 08, 2015 5:05 pm

Alistair...

Attached a stack that will should you how to get hold of the text in your file...:-)
Attachments
getATextFile.zip
(2.47 KiB) Downloaded 126 times

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

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

Post by Klaus » Thu Jan 08, 2015 6:01 pm

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

Post Reply