It used to be very easy to save text from a text field to an external .txt file, but on LiveCode I cannot figure out how to do this. I am a beginning coder, but use livecode to create academic interventions for kindergarten children. I have created a standalone app and I want to be able to keep the data I am collecting in a text field in the app, but each time I quit the app it dumps the data. It would be easy if I could just have a button for the users to click on to save a text file at the end of each session. I would appreciate any help you might offer.
Thank you in advance for your time- I know I must sound like a total noob.
Saving text from text field to .txt file
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: Saving text from text field to .txt file
Not at all - the syntax for this isn't quite as straightforward as some other things in the language.I know I must sound like a total noob.
For a standalone app, if you want to save the text file in the same folder as the app you can just say
Code: Select all
put field "theTextFieldWithTheDataToSave" into url ("file:myTextFile.txt")
PowerDebug http://powerdebug.ahsoftware.net
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
PowerTools http://www.ahsoftware.net/PowerTools/PowerTools.irev
Re: Saving text from text field to .txt file
I'm a beginner too, but one I learned is that you can do this: create a mainstack that serves as a splash screen, and then create a substack for your main application. Any changes to your main application can be saved within the application if you put this into your stack script:rvolpe wrote:I want to be able to keep the data I am collecting in a text field in the app, but each time I quit the app it dumps the data.
Code: Select all
on closeStack
save this stack
pass closeStack
end closeStack
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Saving text from text field to .txt file
...provided you've set the filename property of the stack being saved to a writable location.japino wrote:rvolpe wrote:Any changes to your main application can be saved within the application...
Keep in mind that most OSes won't allow writes to the location where the app is stored, so you'll want to move any savable elements to user-writable folders.
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