How do i specify a database file on the target?

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
Diane
Posts: 20
Joined: Wed Jun 01, 2011 10:02 pm

How do i specify a database file on the target?

Post by Diane » Mon Jun 13, 2011 8:09 pm

Hello, I've been modifying the example database app that reads in data from an existing database file. How do I specify that file directory, when it comes to the target? something like pwd? or here "."?

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: How do i specify a database file on the target?

Post by Mark » Mon Jun 13, 2011 9:47 pm

Hi,

What is "that file directory" and what is "the target" in this context?

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Diane
Posts: 20
Joined: Wed Jun 01, 2011 10:02 pm

Re: How do i specify a database file on the target?

Post by Diane » Mon Jun 13, 2011 9:58 pm

Hi Mark, Oops, I don't think I explained that very well. I would like to "port" the example that Eleanor did in the webinar to the iOS simulator for now, and eventually to the iPhone. In her example, she used specialFolderPath "Desktop", which I'd like to replace with something comparable that will work in both settings. Thanks!

dglass
Posts: 519
Joined: Thu Sep 24, 2009 9:10 pm
Location: California
Contact:

Re: How do i specify a database file on the target?

Post by dglass » Mon Jun 13, 2011 10:16 pm

specialfolderPath("documents") should get you a user-writable folder path regardless of platform/target.

P.S. I think you confuse things when you post about Summer Academy webinars outside of the Summer Academy forum.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: How do i specify a database file on the target?

Post by Mark » Mon Jun 13, 2011 10:28 pm

Hi Diane,

OK, it is getting clearer. First, you need to make sure that you always have the database file in the same folder as your mainstack. Once you have done this you can use several methods to get the path to your file, depending on the final structure of your standalone.

-- method 1
set the itemDel to slash
put item 1 to -2 of the effective filename of this stack into myPath
put "/TheNameOfDatabaseFile.db" after myPath

-- method 2 (iOS only)
put specialfolderpath("engine") into myPath
put "/TheNameOfDatabaseFile.db" after myPath

Specialfolderpath("documents") is useful for saving data, but I don't think that files included in the standalone settings can be written directly to the documents folder. You can, however, include a gzipped file in the standalone package and copy an uncompressed version of it to the documents folder. Just read the file, use the decompress() function and save the output to a file in the documents folder.

In the standalone builder, you need to make sure that your database file is included in the Copy Files section.

Btw it is kind of funny how the specialfolderpath() function doesn't actually return the engine but rather the folder containing the engine (.app is an extension for an application package, which is actually a folder).

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Diane
Posts: 20
Joined: Wed Jun 01, 2011 10:02 pm

Re: How do i specify a database file on the target?

Post by Diane » Mon Jun 13, 2011 11:26 pm

Hello,
Mark, I tried Method 1 and it works great! Works in the development setup, and in the simulator too! Cool! :D
DGlass, I didn't realize that there's a Summer Academy forum! Where is it?
Thanks for your help!
Diane

dglass
Posts: 519
Joined: Thu Sep 24, 2009 9:10 pm
Location: California
Contact:

Re: How do i specify a database file on the target?

Post by dglass » Tue Jun 14, 2011 12:33 am

If you are enrolled you should have a 'Summer Academy' in a 'Private' section at the bottom of the main board index.

If you don't have that, contact customer service so they can set up your access.

Diane
Posts: 20
Joined: Wed Jun 01, 2011 10:02 pm

Re: How do i specify a database file on the target?

Post by Diane » Tue Jun 14, 2011 2:03 am

Hi DGlass, I don't see anything like that, so I'll inquire. Thanks!

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”