
path to the .livecode file I'm working on
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
path to the .livecode file I'm working on
Section 11.1 File Name Specifications and File Paths goes to great length explaining paths and folders, but I can't find a way to get the folder where my current application is--in the development environment, not as a standalone. While I work on it, the defaultFolder tells me where LC is installed, but I want to use relative paths to the folder where my .livecode file is stored. Any Director programmer will know that I'm looking for "the moviePath" 

Re: path to the .livecode file I'm working on
sp27...
This will set the defaultFolder to be the folder that contains the stack on which you are working. Also, have a look at 'specialFolderPath' in the dictionary...
take care
Dixie
This will set the defaultFolder to be the folder that contains the stack on which you are working. Also, have a look at 'specialFolderPath' in the dictionary...
Code: Select all
on preOpenStack
set itemDel to "/"
set the defaultFolder to item 1 to -2 of (the effective fileName of this stack)
end preOpenStack
Dixie
Re: path to the .livecode file I'm working on
Cool--thanks, Dixie!
-
- VIP Livecode Opensource Backer
- Posts: 10043
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: path to the .livecode file I'm working on
I've found the default folder somewhat problematic because it can be changed at any time.
So I've been using the fileName property of the stack, which will work well in both the IDE and in a standalone. Note that in a standalone on OS X it will point to the executable within the bundle, so you may want to account for that if you need to get the back to the folder the bundle is in.
So I've been using the fileName property of the stack, which will work well in both the IDE and in a standalone. Note that in a standalone on OS X it will point to the executable within the bundle, so you may want to account for that if you need to get the back to the folder the bundle is in.
Code: Select all
function StackFolder pStackName
set the itemdel to "/"
-- "effective filename" lets this work on substacks as well as mainstacks:
put the effective filename of stack pStackName into tPath
delete last item of tPath
return tPath
end StackFolder
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: path to the .livecode file I'm working on
Try using 'the Current Folder' the same way you used to use 'the MoviePath' in Director. I just spent half the afternoon duking it out with the correct file path syntax to get to a local html file using a relative path. The User Guide sorta gave hints, but wouldn't just come right out and say that you need to cite a full path using the Current Folder as the lead segment.sp27 wrote:Section 11.1 File Name Specifications and File Paths goes to great length explaining paths and folders, but I can't find a way to get the folder where my current application is--in the development environment, not as a standalone. While I work on it, the defaultFolder tells me where LC is installed, but I want to use relative paths to the folder where my .livecode file is stored. Any Director programmer will know that I'm looking for "the moviePath"
Here is an example that will give you the idea (I hope). Bottom line is that it works for me: "put revBrowserOpen(tWinID,"file:"& the current folder & "/BootsQuestion/quiz.html") into sBrowserId."
This is, of course just one line of code that also contains some variables aren't important to the topic at hand, but it contains a relative path using Current Folder the same way I would have previously used the MoviePath. The user guide sorta kinda makes out like you can create a relative path by using only the path downstream of the folder containing your authoring or standalone exectutible, but that doesn't appear to be the case. I tried everything, and had to introduce the Current Folder to give the function the full path to my html. Go ahead and type "the current folder" into the message box, and it'll kick the full path to your application right back just like the moviepath would in Director.
By the way, all of the revBrowser examples used http://, ftp://, etc. because it was assumed that you would want html from the net. I had to really dig to find out how to use "file:" in place of "http://" to get to a local file. Maybe I'm just not experienced enough to figure that out right off, but it sure didn't jump off the pages of the guide.
Re: path to the .livecode file I'm working on
You can, and it is, but you have to be aware of the current directory. By the way, in case you happen to see us using different syntax, these are all synonyms:Gene wrote:sp27 wrote: The user guide sorta kinda makes out like you can create a relative path by using only the path downstream of the folder containing your authoring or standalone exectutible, but that doesn't appear to be the case.
the directory
the defaultfolder
the current folder
As RIchard mentioned, the defaultfolder (current folder, directory) can change depending on your scripts so you need to keep track of where it is if you want to use relative file paths. All relative file paths use the current folder as their base. When your standalone launches, the current folder is the one containing the standalone, but in the IDE it can change. However, when the IDE is first launched, the default folder is the one containing LiveCode.
Let's say you've just launched LiveCode and you haven't changed the folder. In that case, a file named "foo.txt" would be assumed to live in the same folder with the LiveCode program. Now let's say your scripts have set the default folder to somewhere else at some point:
Code: Select all
set the defaultfolder to specialfolderpath("desktop")
If you aren't sure what the current directory is, then providing a full path as you did is always safe. In fact, it's usually safer to just go ahead and do that anyway unless you are keeping track of locations carefully in your scripts.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: path to the .livecode file I'm working on
This is not relevant to the discussion, but please be careful when you quote other posters. Poster "sp27" would never have said "...sorta kinda makes out like you can..." It's just not his style 

Re: path to the .livecode file I'm working on
Sorry, sp27, I meant no offense, and I wouldn't ever put words into someone else's mouth in any case. However if you look at my original message, my quote from your message did not contain "sorta kinda." That was in the text of what I wrote, not the your original message text. Somehow, though, the reply to my message contains a quoted section that somehow attributes the "sorta kinda" to you
I think it was due to the way the forum automatically handles quotes of quoted text. Anyway, like you said, it's off topic, and I shouldn't compound things by being defensive. I knew I was going to get myself in trouble a some point if I posted to the forum, so I guess this is was it!
I do appreciate Jacques patient explanation, though, even if I still have some questions.

I do appreciate Jacques patient explanation, though, even if I still have some questions.
Re: path to the .livecode file I'm working on
Apologies, I'm pretty sure I must have trimmed the message incorrectly. I'm not quite sure how the quote ended up attributed to you, sp7, but I"ll try to keep a better watch on things.
On the other hand, I would probably say "sorta kinda".
On the other hand, I would probably say "sorta kinda".

Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: path to the .livecode file I'm working on
Thanks, Jacque. I'm a newcomer here, and I hesistate to add yet another message to this thread, but I do want say that this forum is probably the most enjoyable and useful forums I have ever participated in. Everyone is polite and respectful of one another, and the posts are meaningful and intelligent. It's a pleasure to be associated with this community. QED.
Re: path to the .livecode file I'm working on
Likewise here!!!
sp27
sp27