LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!
I have been trying to read the contents of a text file into a variable and cannot get the script in a button to work. I wrote the word "hello" into the first line of this text file, saving it in the default folder where the stack is located.
on mouseUp
answer file "a text file"
if it = "" or the result = "cancel" then
beep
exit mouseUp
end if
put it into thePath
if there is no file thePath then
beep
exit mouseUp
end if
put url ("file:" & thePath) into theFile
answer theFile
end if
I'd also suggest using "put theFile" instead of "answer theFile" but that's certainly a matter of taste...
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
your first script was OK, but you started with the offset "... at -1" which is the end of the file, so you got nothing
AND you did not add the suffix in the line: "read from file...", know what I mean?
...
open file "holder.txt"...
read from file "holder"...
..