desktop and standalone

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

tyarmsteadBUSuSfT
Posts: 151
Joined: Sat Aug 25, 2012 1:14 am

Re: desktop and standalone

Post by tyarmsteadBUSuSfT » Sat Jul 09, 2022 4:33 pm

Thank you.
I think the problem is getting the file into the documents/sandbox. Currently I am using this code at startup:

If there is not a file (URL "file:" & specialFolderPath("documents") & "/CarBuildApp" & "/Receipt.txt") then
put empty into URL ("file:" & specialFolderPath("documents") & "/CarBuildApp" & "/Receipt.txt")
end if

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: desktop and standalone

Post by jacque » Sat Jul 09, 2022 6:44 pm

With respect to the mobile build: How are you getting the text file into the mobile sandboxed Documents folder? I wonder if this is the problem you're having?
That could certainly be the problem. I ran into the same thing recently and there is no way currently to access the public device folders. I've submitted a feature request for it.

One workaround for now is to upload the file to a server and then have the app download it. Or you could copy the text to the clipboard with a text editor and have the app get it from there. Neither method is suitable for a professional app.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

SparkOut
Posts: 2943
Joined: Sun Sep 23, 2007 4:58 pm

Re: desktop and standalone

Post by SparkOut » Sat Jul 09, 2022 9:15 pm

tyarmsteadBUSuSfT wrote:
Sat Jul 09, 2022 4:33 pm
If there is not a file (URL "file:" & specialFolderPath("documents") & "/CarBuildApp" & "/Receipt.txt") then
Looks wrong, I don't think you need to mix the file and URL syntax

Code: Select all

If there is not a file (specialFolderPath("documents") & "/CarBuildApp" &  "/Receipt.txt") then
might be better, but I'm not sure what you're trying to do. If there isn't a file, then create an empty file? Do you populate and save this later?

stam
Posts: 3061
Joined: Sun Jun 04, 2006 9:39 pm

Re: desktop and standalone

Post by stam » Sun Jul 10, 2022 12:24 pm

SparkOut wrote:
Sat Jul 09, 2022 9:15 pm
Looks wrong, I don't think you need to mix the file and URL syntax
1: The OP is looking to import a text file - the URL syntax is correct as per the documentation:
dictonary - file.jpg
2: The issue is how to access a text file on mobile, as actually this is the sticking point. AFAIK, LC does not offer an API for general non-sandboxed files folder (which does exist at least for iOS, i presume for Android as well). The other option is to get this from a web service - either an API or storage like Dropbox (or copy it to clipboard).

The real question is how does the OP plan to derive the text file? is it something generated inside the app? If it's user-entered with the app, you can just use the sandboxed Documents folder of course, but otherwise need another way to get the text data in. It really depends on the OP's planned workflow...

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: desktop and standalone

Post by Klaus » Sun Jul 10, 2022 12:29 pm

Hi stam,
stam wrote:
Sun Jul 10, 2022 12:24 pm
SparkOut wrote:
Sat Jul 09, 2022 9:15 pm
Looks wrong, I don't think you need to mix the file and URL syntax
1: The OP is looking to import a text file - the URL syntax is correct as per the documentation:dictonary - file.jpg
...
true, but Sparkout meant the syntax for checking the existence of that file:
SparkOut wrote:
Sat Jul 09, 2022 9:15 pm
tyarmsteadBUSuSfT wrote:
Sat Jul 09, 2022 4:33 pm
If there is not a file (URL "file:" & specialFolderPath("documents") & "/CarBuildApp" & "/Receipt.txt") then
Looks wrong, I don't think you need to mix the file and URL syntax

Code: Select all

If there is not a file (specialFolderPath("documents") & "/CarBuildApp" &  "/Receipt.txt") then...
Best

Klaus

stam
Posts: 3061
Joined: Sun Jun 04, 2006 9:39 pm

Re: desktop and standalone

Post by stam » Sun Jul 10, 2022 12:40 pm

I stand corrected, Sorry Sparkout!!!
I didn’t see the OPs further post, just the original code.

On that point (now that I actually read the post sparkout was responding to ;) ), not sure why the OP would need to create an empty file if one doesn’t exist? I can’t imagine that serves a purpose?
Check the file when populating the data grid, if it snempty then data grid will be empty, if not populate it. Can’t see a reason for creating an empty file?
All the OP would need to do when reading data in the data grid is start with

Code: Select all

If there is not a file (<fikepath, not URL>) the 
   Set the dgData of group “<data grid name>” to empty
   Exit to top
End if
Or even better, just use the existing code as is with a different modification: check the result after trying to read the file and if this shows an error then pout empty into dgData - should catch any file IO error…

In trying to help the OP, this point still stands however:
stam wrote:
Sun Jul 10, 2022 12:24 pm
The real question is how does the OP plan to derive the text file? is it something generated inside the app? If it's user-entered with the app, you can just use the sandboxed Documents folder of course, but otherwise need another way to get the text data in. It really depends on the OP's planned workflow...

tyarmsteadBUSuSfT
Posts: 151
Joined: Sat Aug 25, 2012 1:14 am

Re: desktop and standalone

Post by tyarmsteadBUSuSfT » Sun Jul 10, 2022 6:25 pm

Thank all for the input. Yes my issue s when the user saves data, I need it to save to the file then when the user goes to the data grid card they are able to see the list of their saved data. The reason I was creating a file ate startup I did, t thing LC would create the file when the user first saved the first entry. I tried to copy the file as part of the standalone settings but I still could not retrieve the data. Should I have copy the files and then used "engine" instead of "documents"
Thank you
Ty

SparkOut
Posts: 2943
Joined: Sun Sep 23, 2007 4:58 pm

Re: desktop and standalone

Post by SparkOut » Sun Jul 10, 2022 7:02 pm

1) don't use specialFolderPath ("engine") - instead, use specialFolderPath ("resources")
2) specialFolderPath ("resources") (or 'engine') is a read only location, so if you need to save updates, you should copy it to specialFolderPath ("documents") on first run. This is where you should check for the existence of the file in "documents" and if not there, then copy from "resources".

tyarmsteadBUSuSfT
Posts: 151
Joined: Sat Aug 25, 2012 1:14 am

Re: desktop and standalone

Post by tyarmsteadBUSuSfT » Sun Jul 10, 2022 9:33 pm

Thank you, I'll give it a go.
Thanks all. of you for the help esp. on a weekend.
Ty

Post Reply