how to retrieve the script path ?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
orducom1
Posts: 6
Joined: Fri Apr 12, 2013 10:20 am

how to retrieve the script path ?

Post by orducom1 » Thu Apr 25, 2013 10:11 pm

Hi folks,

I wish retrieve the path of my file.livecode in a global variable with a function.
When I worked with vbscript, I had a property of wscript object which allowed to retrieve the path of the script, like this :

Code: Select all

Path = Left(WScript.ScriptFullName, InStr(WScript.ScriptFullName, WScript.ScriptName)-1)
Is it exists something like this in Livecode?

Thx by advance for your feedback :)

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: how to retrieve the script path ?

Post by Simon » Thu Apr 25, 2013 10:28 pm

Here it is:

Code: Select all

 
   set itemDel to "/" 
   set the defaultfolder to item 1 to -2 of (the effective fileName of this stack)
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

orducom1
Posts: 6
Joined: Fri Apr 12, 2013 10:20 am

Re: how to retrieve the script path ?

Post by orducom1 » Thu Apr 25, 2013 10:48 pm

Thx Simon for your quick answer
I try it tomorow ... It's midnight in France ;)

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: how to retrieve the script path ?

Post by Simon » Thu Apr 25, 2013 11:46 pm

Oh! And welcome to the forum! :D
Make sure you read up on what the defaultFolder is.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

orducom1
Posts: 6
Joined: Fri Apr 12, 2013 10:20 am

Re: how to retrieve the script path ?

Post by orducom1 » Fri Apr 26, 2013 7:26 am

Great ! It's run !!!

Code: Select all

on mouseUp
   answer appPath()
end mouseUp

function appPath
   set the itemDelimiter to slash
   get the effective filename of this stack
   set the defaultFolder to item 1 to -2 of it
   return defaultFolder
end appPath
Many thx Simon ;)

Post Reply