preOpenStack or openStack

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: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
Turtle
Posts: 3
Joined: Thu Nov 30, 2017 6:33 am

preOpenStack or openStack

Post by Turtle » Wed Dec 06, 2017 11:12 pm

Hi everyone,
Again it is me with the files problem :D
Ok, first i got problem opening the database file, but then i found a topic in the forum which helped me to understand why i need to copy my sqlite file before trying to use it.
Now, my question is this... is it a good idea to call my dataDbConnect function in preOpenStack? Please see the code bellow.

Code: Select all

on dataDbConnect
   put specialfolderpath("resources") & "/data.sqlite" into tDatabasePath
   put  specialfolderpath("Documents") & "/data.sqlite" into tAccessibleDatabasePath
   -- copy it out of the application folder if you dont want to spend your hours pulling your hair
   --trying to understand whats wrong
    put URL ("binfile:" & tDatabasePath) into URL ("binfile:" & tAccessibleDatabasePath)

   put revOpenDatabase("sqlite", tAccessibleDatabasePath, , , , ) into tID
   answer tID
   put tID into gDataDbID
   
end dataDbConnect
Also one more question, is it necessary to add some application permission for reading and writing files in documents file?
Thanks

Klaus
Posts: 9614
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: preOpenStack or openStack

Post by Klaus » Thu Dec 07, 2017 12:57 pm

Hi Turtle,
Turtle wrote:
Wed Dec 06, 2017 11:12 pm
... is it a good idea to call my dataDbConnect function in preOpenStack?
no problem in the IDE, but in a standalone this might not work, due to the way LC loads its externals like the database driver. In that case I would:

Code: Select all

on preopenstack
  ## your preopenstack stuff here...
  send "dataDbConnect" to me in 30 
  ## = 30 ticks = 0.5 seconds  
end preopenstack
This way the engine has time to load all externals etc.
Turtle wrote:
Wed Dec 06, 2017 11:12 pm
... is it necessary to add some application permission for reading and writing files in documents file?
Sorry, don't understand your question? "documents file"? :shock:


Best

Klaus

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4979
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: preOpenStack or openStack

Post by dunbarx » Thu Dec 07, 2017 2:48 pm

Klaus.

I guess he means the documents folder, not file. This folder is unfettered, and usually does not require any special treatment regarding permissions, correct?..

Craig

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

Re: preOpenStack or openStack

Post by SparkOut » Thu Dec 07, 2017 5:02 pm

On mobile maybe you need to ensure the right permissions and inclusions are specified in the standalone settings.
Oh and for the handler above, perhaps you would need a check for the existence of the accessible database file in the documents folder, and only do the copy from resources folder if it isn't there. Otherwise every time you open the stack the database will be overwritten with the original empty one.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”