Hello! First of many stupid questions 8-)

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
SethMould
Posts: 6
Joined: Tue Oct 06, 2015 3:02 pm

Hello! First of many stupid questions 8-)

Post by SethMould » Tue Oct 06, 2015 3:07 pm

Hello. I'm a Visual Basic coder with 30 years IT experience, mental issues, and senility.

I want to read from a file containing 4-letter words:

abed
abet
able...

into a String:

open file specialFolderPath("desktop") & "/CatsDogs.txt" for read
read from file specialFolderPath("desktop") & "/CatsDogs.txt" until eof
put it into tAnswer
answer tAnswer

No joy 8-(

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Re: Hello! First of many stupid questions 8-)

Post by SparkOut » Tue Oct 06, 2015 3:22 pm

If you are going to read in the whole file in one go, the simple syntax is

Code: Select all

put url ("file:" & specialFolderPath("desktop") & "/CatsDogs.txt") into tAnswer

SethMould
Posts: 6
Joined: Tue Oct 06, 2015 3:02 pm

Re: Hello! First of many stupid questions 8-)

Post by SethMould » Tue Oct 06, 2015 3:27 pm

Ok Thanks. Will try that. Then I can Randomize an entry based on the length of tAnswer/4 8-)

SethMould
Posts: 6
Joined: Tue Oct 06, 2015 3:02 pm

Re: Hello! First of many stupid questions 8-)

Post by SethMould » Tue Oct 06, 2015 3:29 pm

Nope. This doesn't work:

put url ("file:" & specialFolderPath("desktop") & "/CatsDogs.txt") into tAnswer
answer tAnswer

SethMould
Posts: 6
Joined: Tue Oct 06, 2015 3:02 pm

Re: Hello! First of many stupid questions 8-)

Post by SethMould » Tue Oct 06, 2015 3:36 pm

OK worked it out. The FilePath was wrong. But I didn't get a "File Not Found" 8-(

zaxos
Posts: 222
Joined: Thu May 23, 2013 11:15 pm

Re: Hello! First of many stupid questions 8-)

Post by zaxos » Tue Oct 06, 2015 5:50 pm

Code: Select all

open file specialFolderPath("desktop") & "/CatsDogs.txt" for read
put the result
this would tell you if the file was found or not, i think its empty if the file is found.
Knowledge is meant to be shared.

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

Re: Hello! First of many stupid questions 8-)

Post by Klaus » Tue Oct 06, 2015 5:53 pm

Same for the URL syntax:
...
put url ("file:" & specialFolderPath("desktop") & "/CatsDogs.txt") into tAnswer
answer the result
...
"the result" will be empty on success!

Post Reply