Get the app directory

Deploying to Windows? Utilizing VB Script execution? This is the place to ask Windows-specific questions.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
alemrantareq
Posts: 203
Joined: Wed Jul 23, 2008 8:46 am

Get the app directory

Post by alemrantareq » Mon Nov 02, 2009 7:39 am

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.

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

Post by Mark » Mon Nov 02, 2009 9:32 am

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
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

alemrantareq
Posts: 203
Joined: Wed Jul 23, 2008 8:46 am

Post by alemrantareq » Mon Nov 02, 2009 1:18 pm

Hi Mark,
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
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. :lol:

 

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

Post by Mark » Mon Nov 02, 2009 1:55 pm

alemrantareq,

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

alemrantareq
Posts: 203
Joined: Wed Jul 23, 2008 8:46 am

Re: Get the app directory

Post by alemrantareq » Sat Nov 21, 2009 10:02 am

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?

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

Re: Get the app directory

Post by Mark » Sat Nov 21, 2009 10:15 am

alemrantareq,

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)
I think you could have figured this out by yourself. Why don't you want to use the shell function?

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

alemrantareq
Posts: 203
Joined: Wed Jul 23, 2008 8:46 am

Re: Get the app directory

Post by alemrantareq » Thu Nov 26, 2009 5:37 pm

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 :)

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Get the app directory

Post by FourthWorld » Thu Nov 26, 2009 6:53 pm

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
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

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

Re: Get the app directory

Post by Mark » Thu Nov 26, 2009 6:56 pm

Hi Richard,

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

alemrantareq
Posts: 203
Joined: Wed Jul 23, 2008 8:46 am

Re: Get the app directory

Post by alemrantareq » Sat Dec 26, 2009 5:59 pm

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?

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Get the app directory

Post by FourthWorld » Sat Dec 26, 2009 6:32 pm

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

alemrantareq
Posts: 203
Joined: Wed Jul 23, 2008 8:46 am

Re: Get the app directory

Post by alemrantareq » Sun Dec 27, 2009 11:21 am

Dear FourthWorld, Thanks for your information. The following works with me nicely -

Code: Select all

put the defaultfolder into tfolder
set the itemdel to "/"
put item -1 of tfolder into tvar
Now, the "tvar" variable holds my app's folder name
 

Post Reply