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
-
lemodizon
- Posts: 219
- Joined: Thu Apr 05, 2018 3:33 pm
Post
by lemodizon » Wed Jun 15, 2022 6:10 am
Hi Everyone,
I used this syntax to locate my database and it works fine.
Question what if my database is in the sub-folder of documents.
ex. Documents>>Database>>DBInv.db
What is the syntax for that? I just want to keep my database private.
hope you can help me.
Thank you in advance.
Code: Select all
command DBConnect
local lDatabaseFile
global gDatabaseID
put specialFolderPath("Documents") & "\DBInv.db" into lDatabaseFile
if there is no file lDatabaseFile then
Beep
Answer Error "No Database Found!" titled ""
else
put revOpenDatabase("Sqlite", lDatabaseFile) into gDatabaseID
answer gDatabaseID
end if
end DBConnect
Thank you & God Bless Everyone
Regards,
lemodizon
-
marksmithhfx
- VIP Livecode Opensource Backer

- Posts: 931
- Joined: Thu Nov 13, 2008 6:48 am
Post
by marksmithhfx » Wed Jun 15, 2022 9:43 am
lemodizon wrote: ↑Wed Jun 15, 2022 6:10 am
Hi Everyone,
I used this syntax to locate my database and it works fine.
Question what if my database is in the sub-folder of documents.
ex. Documents>>Database>>DBInv.db
What is the syntax for that?
Try this:
Code: Select all
put specialFolderPath("Documents") & "\Database\DBInv.db" into lDatabaseFile
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS
-
jacque
- VIP Livecode Opensource Backer

- Posts: 7390
- Joined: Sat Apr 08, 2006 8:31 pm
-
Contact:
Post
by jacque » Wed Jun 15, 2022 5:33 pm
Also, you need forward slashes: / in the path.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
-
lemodizon
- Posts: 219
- Joined: Thu Apr 05, 2018 3:33 pm
Post
by lemodizon » Thu Jun 16, 2022 1:58 am
marksmithhfx wrote: ↑Wed Jun 15, 2022 9:43 am
lemodizon wrote: ↑Wed Jun 15, 2022 6:10 am
Hi Everyone,
I used this syntax to locate my database and it works fine.
Question what if my database is in the sub-folder of documents.
ex. Documents>>Database>>DBInv.db
What is the syntax for that?
Try this:
Code: Select all
put specialFolderPath("Documents") & "\Database\DBInv.db" into lDatabaseFile
Hi marksmithhfx ,
Thanks it works.
How about if the database is in another drive D?
Ex. D:>>Database Folder>>DBFile
i don't if the code is right
Code: Select all
put specialFolderPath("I don't know what to input here") & "D:\Database\DBInv.db" into lDatabaseFile
[/quote]
Thanks again
Thank you & God Bless Everyone
Regards,
lemodizon
-
lemodizon
- Posts: 219
- Joined: Thu Apr 05, 2018 3:33 pm
Post
by lemodizon » Thu Jun 16, 2022 2:00 am
jacque wrote: ↑Wed Jun 15, 2022 5:33 pm
Also, you need forward slashes: / in the path.
Hi jacque ,
Thanks. correct me if I got it wrong.
Code: Select all
put specialFolderPath("Documents") & "\Database\DBInv.db/" into lDatabaseFile
is this correct?
Thank you & God Bless Everyone
Regards,
lemodizon
-
jacque
- VIP Livecode Opensource Backer

- Posts: 7390
- Joined: Sat Apr 08, 2006 8:31 pm
-
Contact:
Post
by jacque » Thu Jun 16, 2022 5:42 am
If Mark's way works then you can use it, but I'm a little surprised if it does work since LC uses forward slashes for all file paths. Normally we'd use this:
Code: Select all
put specialFolderPath("Documents") & "/Database/DBInv.db" into lDatabaseFile
LC will convert the slashes to the correct one for the current OS.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
-
golife
- Posts: 115
- Joined: Fri Apr 02, 2010 12:10 pm
Post
by golife » Thu Jun 16, 2022 4:20 pm
Windows 10 / 11
On my Windows 11 machine I do not get the fully resolved path if concatenating with other path information using specialfolderpath("whatever") &"/foldername/foldername/filename" and storing the path in a variable.
Code: Select all
# Here is a non-working and working line in my Windows environment
put specialFolderPath ( "documents") & "/LC/data" into tPath -- will not work. The variable is not recognized as a path.
put ( specialFolderPath ("documents") & "/LC/data" ) into tPath -- works using parenthesis. The variable is recognized.
-
stam
- Posts: 3069
- Joined: Sun Jun 04, 2006 9:39 pm
Post
by stam » Thu Jun 16, 2022 4:24 pm
golife wrote: ↑Thu Jun 16, 2022 4:20 pm
Windows 10 / 11
On my Windows 11 machine I do not get the fully resolved path if concatenating with other path information using specialfolderpath("whatever") &"/foldername/foldername/filename" and storing the path in a variable.
Code: Select all
# Here is a non-working and working line in my Windows environment
put specialFolderPath ( "documents") & "LC/data" into tPath -- will not work. The variable is not recognized as a path.
put ( specialFolderPath ("documents") & LC/data" ) into tPath -- works using parenthesis. The variable is recognized.
i'm sure it's a typo, but your second line is missing a quote.
However, both lines are wrong as you need to add a preceding slash to the second part, ie :
Code: Select all
specialFolderPath("documents") & "/LC/data"
Might that be what's troubling your failed attempt (ie. typo of some kind)?
Last edited by
stam on Thu Jun 16, 2022 4:27 pm, edited 1 time in total.
-
golife
- Posts: 115
- Joined: Fri Apr 02, 2010 12:10 pm
Post
by golife » Thu Jun 16, 2022 4:26 pm
Typo happens... )) Thank you for pointing it out. Corrected.
-
marksmithhfx
- VIP Livecode Opensource Backer

- Posts: 931
- Joined: Thu Nov 13, 2008 6:48 am
Post
by marksmithhfx » Sat Jun 18, 2022 7:36 pm
lemodizon wrote: ↑Wed Jun 15, 2022 6:10 am
How about if the database is in another drive D?
Ex. D:>>Database Folder>>DBFile
i don't if the code is right
Code: Select all
put specialFolderPath("I don't know what to input here") & "D:\Database\DBInv.db" into lDatabaseFile
I guess the best way to find out is to try it. I've never had more than 1 drive so I don't know
To answer your specialfolderpath question I suggest checking the LC dictionary. It has all of the options listed.
Best,
Mark
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS
-
lemodizon
- Posts: 219
- Joined: Thu Apr 05, 2018 3:33 pm
Post
by lemodizon » Mon Jun 20, 2022 1:59 am
marksmithhfx wrote: ↑Sat Jun 18, 2022 7:36 pm
lemodizon wrote: ↑Wed Jun 15, 2022 6:10 am
How about if the database is in another drive D?
Ex. D:>>Database Folder>>DBFile
i don't if the code is right
Code: Select all
put specialFolderPath("I don't know what to input here") & "D:\Database\DBInv.db" into lDatabaseFile
I guess the best way to find out is to try it. I've never had more than 1 drive so I don't know
To answer your specialfolderpath question I suggest checking the LC dictionary. It has all of the options listed.
Best,
Mark
Hi marksmithhfx ,
Thank you. I will try. hope i can find the answer there.
Thank you & God Bless Everyone
Regards,
lemodizon
-
SparkOut
- Posts: 2944
- Joined: Sun Sep 23, 2007 4:58 pm
Post
by SparkOut » Mon Jun 20, 2022 7:24 am
I think what might have been missed is that you already have the full path to the database file.
You don't need specialFolderPath at all for this case.