Directory Confusion

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
lohill
Posts: 770
Joined: Tue Dec 08, 2009 6:37 pm
Location: San Diego, CA USA

Directory Confusion

Post by lohill » Sun Dec 18, 2016 8:36 pm

There seems to be a difference between versions 7.1.3 and 8.1.1 in how it handles 'directory' or 'folder'. This can easily be tested by putting a button on a new stack with the following code:

Code: Select all

on mouseUp
   put the directory into tDirectory
   answer tDirectory
end mouseUp
In 7.1.3 i get "/Users/lohill/Applications" while on version 8.1.1 I get "/Users/lohill/Applications/LiveCode Indy 8.1.1.app".
Is there a way to get the former result in the latter engine without having to do something gross like set the itemdelimiter to "/" and then delete the last item of the directory I get in 8?

Thanks,
Larry

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Directory Confusion

Post by [-hh] » Mon Dec 19, 2016 12:09 am

You could try (for example in openstack)

Code: Select all

set directory to "/Users/lohill/Applications"
shiftLock happens

lohill
Posts: 770
Joined: Tue Dec 08, 2009 6:37 pm
Location: San Diego, CA USA

Re: Directory Confusion

Post by lohill » Mon Dec 19, 2016 12:16 am

That might work for me alone but if I compile this stack and give it to someone else they won't have a directory that looks like that. I actually want to know the directory they are in so I can set the directory to that.

Larry

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Directory Confusion

Post by [-hh] » Mon Dec 19, 2016 1:06 am

Oh, a more general question (and answer). So you could try

Code: Select all

on mouseUp
   set directory to getStackDir()
end mouseUp

function getStackDir
   set itemdel to slash
   return item 1 to -2 of the effective filename of this stack
end getStackDir
Tried with a new stack, works here in LC 6/7/8/9.
For an earlier answer I was fooled by old settings, sorry.
(If the value is not a directory when setting the directory, then LC uses its last setting)
shiftLock happens

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7237
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Directory Confusion

Post by jacque » Mon Dec 19, 2016 6:25 pm

It seems there is no easier way to do what you want:

http://quality.livecode.com/show_bug.cgi?id=18008
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”