I managed to save the results of a calculation in the same folder as the app itself using f = New FolderItem(“MyFile”, FolderItem.PathModes.Native).
I’m unable to save it somewhere else, though. In fact, I do not understand how to specify the where and what using a dialog (SaveFileDialog?).
I’d appreciate if anybody can give me an example on how to do it
Amazed you were allowed to do that.
Try this: (API1 syntax)
Dim dlg as New SaveAsDialog
dlg.promptText="Save a file"
the issue is that the comments at the end are wrong
the dialog does not actually SAVE anything - it either gives you a NIL (do not save this) or a place the user selected TO save the file to so you just use the returned folderitem instead of creating one
Var dlg As New SaveFileDialog Var f As FolderItem dlg.InitialFolder = SpecialFolder.Documents dlg.PromptText = "Prompt Text" dlg.SuggestedFileName = "Suggested Filename" dlg.Title = "Title Property" dlg.Filter = FileTypes1.Text // defined as a file type in FileTypes1 file type set f = dlg.ShowModal If f <> Nil Then // this is where the file should be saved Else // user canceled so do nothing End If
So the FolderItem f will be placed placed inside whatever folder was selected by the modal dialog, assuming f is not NIL. The code to save whatever data needs to be stored should work to place everything inside f, and that should be the trick. Am I correct?
Yup. You make a folderitem. Then you get a binarystream and let that write to the folderitem.
It’s still very hazy. As I said, I managed to save and retrieve it if everything goes in the same folder as the app itslef. Choosing a different location is a differen matte altogether.
I attach a link to the application. It is a simple application which determines the date of Easter based on the year. Nothing serious but this virus keeps everybody at home so I have more time to play with Xojo:
Here is my new version: https://www.dropbox.com/s/d7r4gmzfz29q7qv/DataPasqua.zip?dl=0 . I made f a property of the window. That way you can load and save one file. The dialogs are only shown if f = nil. I’ve also corrected the TextAreas so that they load the new valued.
I’m sorry Beatrix, clicking on the link you provided I only get a blank DropBox page with DataPasqua.zip written on top but not clickable, so I cannot download the file.
Could you check the link again or send it some other way?
The applications are meant to resides in the Applications folder.
On macOS, when you save a file into the Applications folder, then decide to move it elsewhere, you will copy a link to that file (you will not move the file).
Also, using a BinaryStream to save text data is not what most of people will do (and if some will do that, they will have a very good reason).
As far as I understand, these are numeric values, save them as is (and read them accordingly, because you will read them at a moment or another).
You do not know how to transform a text data into a numeric data ? Look at the documentation (http://docs.xojo.com/Val and read the See Also paragraph).
At last, you can save the data in a file silently: avoid the dialog display as it is said earlier (above).
The world current situation is stressing, so I can understand you.
In the future, before asking questions here (or waste time searching how to in Xojo), lookhow things are done in the OS (in the above case, TextEdit in macOS, WordPad in Windows): where they want to store the data by default for this example.
These are advices, clues, nothing else.
Use this one:
Note the ending 1 (instead of 0): it says to the web target to download directly the file instead of displaying a download page interface. Sometimes I too forgot the change (in fact I forgot too).
Disregard, thank you. It was probably a glitch in my web services provider but it worked, eventually. I tried your solution and it works very well for me.
Thanks a lot for your help