Page 1 of 1

specialfolder (desktop)

Posted: Wed Jun 15, 2022 6:10 am
by lemodizon
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

Re: specialfolder (desktop)

Posted: Wed Jun 15, 2022 9:43 am
by marksmithhfx
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

Re: specialfolder (desktop)

Posted: Wed Jun 15, 2022 5:33 pm
by jacque
Also, you need forward slashes: / in the path.

Re: specialfolder (desktop)

Posted: Thu Jun 16, 2022 1:58 am
by lemodizon
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

Re: specialfolder (desktop)

Posted: Thu Jun 16, 2022 2:00 am
by lemodizon
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?

Re: specialfolder (desktop)

Posted: Thu Jun 16, 2022 5:42 am
by jacque
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.

Re: specialfolder (desktop)

Posted: Thu Jun 16, 2022 4:20 pm
by golife
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.
   

Re: specialfolder (desktop)

Posted: Thu Jun 16, 2022 4:24 pm
by stam
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)?

Re: specialfolder (desktop)

Posted: Thu Jun 16, 2022 4:26 pm
by golife
Typo happens... )) Thank you for pointing it out. Corrected.

Re: specialfolder (desktop)

Posted: Sat Jun 18, 2022 7:36 pm
by marksmithhfx
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

Re: specialfolder (desktop)

Posted: Mon Jun 20, 2022 1:59 am
by lemodizon
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.

Re: specialfolder (desktop)

Posted: Mon Jun 20, 2022 7:24 am
by SparkOut
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.