Page 1 of 1

Hello! First of many stupid questions 8-)

Posted: Tue Oct 06, 2015 3:07 pm
by SethMould
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-(

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

Posted: Tue Oct 06, 2015 3:22 pm
by SparkOut
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

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

Posted: Tue Oct 06, 2015 3:27 pm
by SethMould
Ok Thanks. Will try that. Then I can Randomize an entry based on the length of tAnswer/4 8-)

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

Posted: Tue Oct 06, 2015 3:29 pm
by SethMould
Nope. This doesn't work:

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

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

Posted: Tue Oct 06, 2015 3:36 pm
by SethMould
OK worked it out. The FilePath was wrong. But I didn't get a "File Not Found" 8-(

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

Posted: Tue Oct 06, 2015 5:50 pm
by zaxos

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.

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

Posted: Tue Oct 06, 2015 5:53 pm
by Klaus
Same for the URL syntax:
...
put url ("file:" & specialFolderPath("desktop") & "/CatsDogs.txt") into tAnswer
answer the result
...
"the result" will be empty on success!