Problem with multiple scripts and Project Builder

I have a project I’m working on that I need to finish up this weekend and I’m having a little problem :slight_smile:

Firstly, I need to ask the location of a folder and retain it indefinitely upon opening the application.

The application consists of 2 buttons which move files around within the folder that was defined by the user.

My question is how can I use choose folder and retain the value within the scripts and then pass it’s value to 2 already existing applescripts.

Here’s one of them for an example:


on clicked theObject
	do shell script "cd " & WolfFolderPath & "; ./wt1"
end clicked

WolfFolderPath being the variable I’m trying to ask and retain.

Thanks in advance

Try this.

put this at the top of your main script:

global WolfFolderPath

This is the way of declaring a ‘global’ variable and will, at the very least, give access to that variable to all routines and handlers in the script. I think the same goes for your other project scripts.

Well, I got things working most of the way by figuring out how to get everything to run within one script:


global WolfFolderPath
global QPWolf

property WolfFolderPath : ""
property QPWolf : ""

on opened theObject
	set QPWolf to (choose folder with prompt "Select the folder where Wolfenstein is located:")
	set WolfFolderPath to the quoted form of POSIX path of QPWolf
end opened

on clicked theObject
	if name of theObject is "Move WolfTactics DLLs" then
		do shell script "cd " & WolfFolderPath & "wolftactics ; ./wt1"
	else if name of theObject is "Move Wolf DLLs" then
		do shell script "cd " & WolfFolderPath & "wolftactics ; ./wt2"
	end if
end clicked

Now, my problem is that the “on opened” will ask for a folder choice each time, and I just want to ask it once, and once only…It’s more of an annoyance than anything, but if I can make it go away or toggle it to ask the question with another button, I’d rather do that.

Any ideas/Suggestions? I realize that either ‘global’ or ‘property’ are probably redundant at this point, but…