Get the app directory
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 203
- Joined: Wed Jul 23, 2008 8:46 am
Get the app directory
Hi everybody,
I need a little help. I want the btn code to open the current directory where my app exists. Before some months, I found that code somewhere but I lost it. "The DefaultFolder" property helps in this way but it puts "/" instead of "\". Pls, help me to get that code. Replies are most appreciated.
I need a little help. I want the btn code to open the current directory where my app exists. Before some months, I found that code somewhere but I lost it. "The DefaultFolder" property helps in this way but it puts "/" instead of "\". Pls, help me to get that code. Replies are most appreciated.
Hi alemrantareq,
What is your current code to open the folder?
Yo don't want to use the defaultFolder. Instead, you want to use:
set the itemdel to slash
put item 1 to -2 of the effective filename of this stack into myFolder
You might want to replace <this stack> with <stack "Your Stack">.
Best,
Mark
What is your current code to open the folder?
Yo don't want to use the defaultFolder. Instead, you want to use:
set the itemdel to slash
put item 1 to -2 of the effective filename of this stack into myFolder
You might want to replace <this stack> with <stack "Your Stack">.
Best,
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
-
- Posts: 203
- Joined: Wed Jul 23, 2008 8:46 am
Hi Mark,
very luckily I've found that code in this forum. This code is -
Mark, this code was posted by you into "Opening a folder in Windows" topic in this Windows forum
http://forums.runrev.com/phpBB2/viewtopic.php?t=1597
I thought it was in "Talking Revolution" section and I gave it a deep search, but nothing found. After your reply, I made a search in Windows forum and at last, I discovered it.
Thanks a lot for your reply and your code.
Â
very luckily I've found that code in this forum. This code is -
Code: Select all
on mouseUp
set the hideconsolewindows to true
get shell("start" && quote & quote && quote & the defaultfolder & quote)
end mouseUp
http://forums.runrev.com/phpBB2/viewtopic.php?t=1597
I thought it was in "Talking Revolution" section and I gave it a deep search, but nothing found. After your reply, I made a search in Windows forum and at last, I discovered it.
Thanks a lot for your reply and your code.

Â
alemrantareq,
Edgore seemed to have a reason to use the defaultFolder. You will probably want to use the effeective filename instead.
Best,
Mark
Edgore seemed to have a reason to use the defaultFolder. You will probably want to use the effeective filename instead.
Best,
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
-
- Posts: 203
- Joined: Wed Jul 23, 2008 8:46 am
Re: Get the app directory
I don't need the file name, rather I need to open the directory where my app exists. Is there any way to do it without using shell function?
Re: Get the app directory
alemrantareq,
I already understood that you want to get the folder name, but you still will want to use the effective filename.
I think you could have figured this out by yourself. Why don't you want to use the shell function?
Best,
Mark
I already understood that you want to get the folder name, but you still will want to use the effective filename.
Code: Select all
set the itemDel to slash
put item 1 to -2 of the effective filename of this stack into myFolderPath
replace slash with backslash in myFolderPath
set the hideconsolewindows to true
get shell("start" && quote & quote && quote & myFolderPath & quote)
Best,
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
-
- Posts: 203
- Joined: Wed Jul 23, 2008 8:46 am
Re: Get the app directory
Thanks Mark,
I can open the app folder simply with my previous posted code. But I wanted to know if there's another way without using "Shell" function.
Anyway, Thanks you most
I can open the app folder simply with my previous posted code. But I wanted to know if there's another way without using "Shell" function.
Anyway, Thanks you most

-
- VIP Livecode Opensource Backer
- Posts: 10043
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Get the app directory
The default folder for an application is user-settable, so while it defaults to the folder the app is in it may be changed at anytime to anything else.
To get the path to the executable I use the filename property, which has the added benefit of working in the IDE or a standalone.
The function listed in this use-rev post accounts for the differences between Win and OS X and returns the path to the executable:
http://lists.runrev.com/pipermail/metac ... 02553.html
To get the path to the executable I use the filename property, which has the added benefit of working in the IDE or a standalone.
The function listed in this use-rev post accounts for the differences between Win and OS X and returns the path to the executable:
http://lists.runrev.com/pipermail/metac ... 02553.html
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Get the app directory
Hi Richard,
I think you mean effective filename, rather than filename.
Best,
Mark
I think you mean effective filename, rather than filename.
Best,
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
-
- Posts: 203
- Joined: Wed Jul 23, 2008 8:46 am
Re: Get the app directory
Hi, I just need another help. If i use the Defaultfolder property to put it into a variable, it gets the full address of that directory (i.e. C:/Program Files/Revolution Enterprise). But I just need to put only the folder name (i.e. Revolution Enterprise) into a variable instead of the full name. what should i do?
-
- VIP Livecode Opensource Backer
- Posts: 10043
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Get the app directory
Path elements are separated by slashes, and Rev allows you to work with individual items delimited by any character as items. See the itemdelimiter property in the Dictionary.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
-
- Posts: 203
- Joined: Wed Jul 23, 2008 8:46 am
Re: Get the app directory
Dear FourthWorld, Thanks for your information. The following works with me nicely -
Now, the "tvar" variable holds my app's folder name
Code: Select all
put the defaultfolder into tfolder
set the itemdel to "/"
put item -1 of tfolder into tvar