Page 1 of 1

Directory Confusion

Posted: Sun Dec 18, 2016 8:36 pm
by lohill
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

Re: Directory Confusion

Posted: Mon Dec 19, 2016 12:09 am
by [-hh]
You could try (for example in openstack)

Code: Select all

set directory to "/Users/lohill/Applications"

Re: Directory Confusion

Posted: Mon Dec 19, 2016 12:16 am
by lohill
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

Re: Directory Confusion

Posted: Mon Dec 19, 2016 1:06 am
by [-hh]
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)

Re: Directory Confusion

Posted: Mon Dec 19, 2016 6:25 pm
by jacque
It seems there is no easier way to do what you want:

http://quality.livecode.com/show_bug.cgi?id=18008