How do i specify a database file on the target?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
How do i specify a database file on the target?
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 "."?
Re: How do i specify a database file on the target?
Hi,
What is "that file directory" and what is "the target" in this context?
Kind regards,
Mark
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
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: How do i specify a database file on the target?
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!
Re: How do i specify a database file on the target?
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.
P.S. I think you confuse things when you post about Summer Academy webinars outside of the Summer Academy forum.
Re: How do i specify a database file on the target?
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
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
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: How do i specify a database file on the target?
Hello,
Mark, I tried Method 1 and it works great! Works in the development setup, and in the simulator too! Cool!
DGlass, I didn't realize that there's a Summer Academy forum! Where is it?
Thanks for your help!
Diane
Mark, I tried Method 1 and it works great! Works in the development setup, and in the simulator too! Cool!
DGlass, I didn't realize that there's a Summer Academy forum! Where is it?
Thanks for your help!
Diane
Re: How do i specify a database file on the target?
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.
If you don't have that, contact customer service so they can set up your access.
Re: How do i specify a database file on the target?
Hi DGlass, I don't see anything like that, so I'll inquire. Thanks!