If I create an app with a ListBox, Build the app to a Mac desktop version, and then add data to the ListBox - where does XoJo store the listbox data? Can I edit the location?
it doesnt store it anywhere unless you write code to save the data somewhere
technically its is stored in the CELL(x,y) property of the listbox… but as Norman said if you want to “save” it that is up to you
basically listbox stores its data in memory
if you want to save it on disk then you need to write the code to do that
Thanks for the reply.
I was trying this example:
http://xojobyexample.com/url-lister/
If I compile it into an OS X app, add some entries to the list, quit the app, and restart it - the new entries are still there. Why?
Because that example is saving the contents of the listbox to disk and then reading them back when you run it again. I haven’t examined the project, but look in app.open or window.open for the code that reads them in. That will tell you where it is storing the data.
The text says: “URL Lister:
URL Lister shows how to create, edit, and save a list of URLs. You will see how to save the data from a two column listbox to a text file and how to retrieve that data from the saved file. Use of control binding and the ShowURL method are demonstrated.
URL Lister also demonstrates how to search multiple columns in a listbox.”
So the contents of the listbox are saved as a text file and retrieved upon opening…
Thank you - I do indeed see that this code appears to save the data in a file called “URL List Data.” But where is that file saved? It is not inside the package for the app and i cannot figure out what other directory is being used to store this file.
dim f as folderItem
dim i as integer
dim t as textOutputStream
dim theLine as string
f = SpecialFolder.ApplicationData.child(“URL List Data”)
if f <> nil then
t = f.createTextFile
if t <> nil then
for i = 0 to URLlist.listCount -1 //repeat with each row of the listbox
theLine = URLlist.cell(i,0) + chr(9) + URLlist.cell(i,1)
//theLine is made up of the Name + tab character + the URL
t.writeLine theLine
next
t.close
end if
end if
Search SpecialFolder
in the Docs to get its location.
Edit:
Also, use Cmd-F, type URL List Data, add to the search location the system files and you will get it.
Thank you- interesting that it is stored on the Mac in the user’s “Application Support” folder but NOT in the Xojo subfolder.
How would I choose a different (more obvious) location for the data?
How would I let the application user select a specific file each time the app is run?
Follow the previous advice: go to
https://documentation.xojo.com/index.php/SpecialFolder
And remember: you cannot store data where you want (feel / think ) There are places to put them (and it will never bee Xojo own folder: what happend if a user of your software store data: it needs to install Xojo ?).
Asking advice(s) is a good thing. Following some answer(s) can be good too. This is free and comes from Xojo.
[quote=438695:@Emile Schwarz]A better source for learning is located there:
Xojo: Learn Xojo Programming [/quote]
Nota: all dvelopment environments “works the same” for many things. What you are asking now can be asked for any other tool.
Go to https://documentation.xojo.com/
and search for FolderItem
.
Introduction to Programming with Xojo 3rd Edition.pdf
Chapter 9: In and Out talks about reading (files) and writing (files)
I forgot: This is free and have the example projects in the archive.
@Emile Schwarz - Thanks for the help. My point regarding the default location on the Mac is that it is in ~/Library/Application Support. That folder contains subfolders for storing data related to many different installed software packages; there is even a Xojo subfolder.
But for some reason a FolderItem is stored in ~/Library/Application
rather than ~/Library/Application/Xojo
The Xojo subfolder would seem to be more consistent with typical protocol for OS X applications.
[quote=438718:@Richard Kaplan]@Emile Schwarz - Thanks for the help. My point regarding the default location on the Mac is that it is in ~/Library/Application Support. That folder contains subfolders for storing data related to many different installed software packages; there is even a Xojo subfolder.
But for some reason a FolderItem is stored in ~/Library/Application
rather than ~/Library/Application/Xojo
The Xojo subfolder would seem to be more consistent with typical protocol for OS X applications.[/quote]
My guess is that the sample code doesn’t want to mess with files in that Xojo directory and it is too short (missing code) to create a directory where to put the “URL list data” file.
Once you know more and practice, your code should create a subfolder on the SpecialFolder directory for your app, so you can safely save files needed for your app. For your users you should work with OpenDialog and SaveDialog so the users put their data where they want and not in your application data folder.
OS X Applications resides in the Applications folder, nowhere else.
But, you can place them where you want (you are free).
The asked question was where is my listbox data file (as I understand it).
Now, by using Xojo, you are entering in a whole different world where the rules are different (while using Xojo) than when you run Preview or TextEdit or GIMP.
Also, that example store the list at a pre-defined location because it read it from there (consistent behavior).
If you want to let your user(s) to choose the place to save (then read) the list, you already get a couple of anwsers.
Using the https://documentation.xojo.com/ web site allows you to learn what you find in examples (that comes with or without explanations).
Doh: you also have a built-in LR feature to use to get explanations about any element of the Xojo language you may want to get.
At last, you also have an Example Projects
folder inside Applications:Xojo:
.
Time for my daily nap
And doubtless it’s used by the Xojo IDE.
If I have a program called Wiggy, I might expect its support files to be in ~/Library/Application Support/Wiggy/
I’d expect support files for Xojo IDE to be there, not for other people’s programs.
@Tim Streater
If I have a program called Wiggy, I might expect its support files to be in ~/Library/Application Support/Wiggy/
Good point - agreed