Data base error on mac

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

Post Reply
AstghikM
Posts: 45
Joined: Mon Sep 08, 2014 8:35 pm

Data base error on mac

Post by AstghikM »

Hi everyone :)
i have one problem with data base, so the problem is that on mac i get a DB error, but on windows it works without any problem. please can you help me? why does it happen? i am attaching a simple livecode app which works on windows but gives error on mac.
Attachments
test.zip
(48.57 KiB) Downloaded 288 times
Last edited by AstghikM on Fri May 22, 2015 2:55 pm, edited 1 time in total.
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Data base error on mac

Post by Klaus »

Hi AstghikM,

what does the error say and please also post the script that produces the error.


Best

Klaus
AstghikM
Posts: 45
Joined: Mon Sep 08, 2014 8:35 pm

Re: Data base error on mac

Post by AstghikM »

Klaus wrote:Hi AstghikM,

what does the error say and please also post the script that produces the error.


Best

Klaus
Thank you for reply :)
I just attached the file, the error says can't find the table "countries"
ToddFabacher
Posts: 280
Joined: Fri Jan 09, 2015 6:15 pm

Re: Data base error on mac

Post by ToddFabacher »

It seems that it is NOT problem in LiveCode, but only after it is compiled. The error seems to be in runtime, not in the LiveCode IDE.

It is an SQLite database...everything seems to be in order, but it does not work???

--Todd
ToddFabacher
Posts: 280
Joined: Fri Jan 09, 2015 6:15 pm

Re: Data base error on mac

Post by ToddFabacher »

The issue is with the file path. On the Mac during runtime, extra stuff is added to the path so you need to delete the extra to get the effective file path. This code will solve your problem.

Code: Select all

 -- get the file path for this stack
    put the effective filename of this stack into tPath
    set the itemDelimiter to slash
    
    if the platform = "MacOS" and the environment = "standalone application" then
        -- if this is a standalone application running on a Mac, find the path to the .app file
        repeat until last item of tPath contains ".app"
            delete last item of tPath
        end repeat
    end if
    
    -- remove the last item to get the path to the containing folder
    delete last item of tPath
    answer tPath
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Data base error on mac

Post by Klaus »

Hi AstghikM,

AHA! :D

What Todd says, BUT:
1. You should add your SQLite file to your standalone via the "Copy files" tab in the standalone builder!
Then you will find it here in your standalone -> specialfolderpath("engine")

2. Most users are NOT allowed to write in the "Applications" folder (same o Windows!) and even opening that db
is recoginzed as "writing" by the underlying OS, so that may produce an error!

3. Like on the mobile platform you should copy that db file to e.g. the users documents folder when the app starts
the very first time and access the db from there!


Best

Klaus
Post Reply