Trying to bring in text to a field from text file
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Trying to bring in text to a field from text file
I am trying to bring in the text from a text file into a field. I know this should be simple and have done this before in the tutorial on creating a Notes app. Today, I'm trying to do the exact same thing and no luck. I even renamed my file and field to match the tutorial in case I was missing something. So, my field is named notesList and my file is notesList.txt located in my documents folder. I then created the following lines of code. No errors on execution but it did not add the text from the file into the field. The only thing different that I can identify from the time I did the tutorial to today is that I've moved to Win 10. Could that possibly be the issue? If so, any thoughts on how to get around it? Or, can you see what I might be doing wrong? I have to say I'm about to throw in the towel. If I can't get this small piece to work more than once, I'm probably not cut out for using this tool. (sigh)
put specialFolderPath("documents") & "/notesList.txt" into tFile
put URL("File:" & tFile) into field "notesList"
Result: No errors, no change in field notesList. If it matters, notesList field is a scrolling field as used in the tutorial. I've quadruple checked to ensure the proper location of my file.
Any thoughts would be much appreciated!
put specialFolderPath("documents") & "/notesList.txt" into tFile
put URL("File:" & tFile) into field "notesList"
Result: No errors, no change in field notesList. If it matters, notesList field is a scrolling field as used in the tutorial. I've quadruple checked to ensure the proper location of my file.
Any thoughts would be much appreciated!
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Trying to bring in text to a field from text file
If I can use it certainly you can.athelene wrote:If I can't get this small piece to work more than once, I'm probably not cut out for using this tool. (sigh)
One thing that may be helpful is to keep in mind that LiveCode has two types of errors: only the most serious unrecoverable errors will throw an actual error dialog, while for the others we can check a global variable immediately after a command to see if it contains error info, "the result":
Code: Select all
put URL("File:" & tFile) into field "notesList"
if the result is not empty then
answer the result &"( "& sysError() &")"
end if
Add that to your script and try it out, and let us know what you find.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Trying to bring in text to a field from text file
OK! Says: Can't open file (87) Does the 87 point me to any resource that might tell me why it can't open it? Maybe my quadruple check on location was quadruple times wrong?
Can't tell you how much I appreciate your help.
Can't tell you how much I appreciate your help.
Re: Trying to bring in text to a field from text file
Hi athelene,
Here is a quick way to make sure you are in the right place
"it" will contain the complete path to the file.
Simon
Here is a quick way to make sure you are in the right place
Code: Select all
answer file "Pick a file?"
put URL("File:" & it) into field "notesList"
put it
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Trying to bring in text to a field from text file
Thank you!!! Figured it out with your last bit of help. Feeling even more stupid as a result, but very grateful. Turns out the file name was actually notesList.txt.txt. My File Explorer was not showing me extensions. Apparently Livecode can't read my mind and figure out that I am using the wrong filename. Go figure! Anyway, I very much appreciate all the super fast help for this beginner!
I kind of feel like I always feel on the 18th hole of the golf course. You have a lousy game for the first 17 holes. But when you finally get a birdie on 18, you think it's the best game ever and can't wait to play again.
Have a good evening everyone.
I kind of feel like I always feel on the 18th hole of the golf course. You have a lousy game for the first 17 holes. But when you finally get a birdie on 18, you think it's the best game ever and can't wait to play again.

Have a good evening everyone.
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Trying to bring in text to a field from text file
That's not you, that's some OS designer who felt it would be better if the system presented incomplete information to you. File extensions can be very important, and when an OS conceals them from users it gives rise to about as many issues as that design decision is supposed to fix.athelene wrote:Thank you!!! Figured it out with your last bit of help. Feeling even more stupid as a result, but very grateful. Turns out the file name was actually notesList.txt.txt. My File Explorer was not showing me extensions.
Support for psychic code interpretation is slated for v21.Apparently Livecode can't read my mind and figure out that I am using the wrong filename.

Good to see you're still in the game. LiveCode is a strange beast sometimes, different from just about any other programming system you'll find. But for that reason it's also strangely addictive.I kind of feel like I always feel on the 18th hole of the golf course. You have a lousy game for the first 17 holes. But when you finally get a birdie on 18, you think it's the best game ever and can't wait to play again.![]()
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Trying to bring in text to a field from text file
It never ceases to amaze me that someone decided to make a feature to hide the extensions, and especially that it is turned on by default.