Can't create path alias with AppleScript

I’ve got an AppleScript tool that creates the various elements of projects for a certain tool I use.

If I hard-wire the path to the folders, the script works great. If, however, I include an option to “select folder” for data I need to use and include a default starting point, it fails.

Here are the snippets:

#set tm_location to "/Users/bowjest/01 Level/03 Level/10 Level"
set tm_location to choose folder with prompt "TM folder :" default location "/Users/bowjest/01 Level/03 Level/10 Level"
#set glossary_location to "/Users/bowjest/01 Level/03 Level/11 Level"
set glossary_location to choose folder with prompt "Glossary folder :" default location "/Users/bowjest/01 Level/03 Level/11 Level"

If I don’t include the default starting point, it completes the project with no problems. But if I include a default starting point (as above), it produces the following path info in the project:

/Users/bowjest/Desktop/PROJECT/Macintosh HD:Users:bowjest:01 Level:03 Level:10 Level:01 Data:/

The project software can’t cope with the colons that are inserted. If no default starting point is specified, no colons are inserted (but then I have to navigate through a lot of layers of folders, hence my desire to have a default starting point).

Does anyone see where I may have gone wrong? I’ve tried everything I can think of, but so far can’t get this to work.

Thanks

Hi,

this is the most common error in AppleScript.
AppleScript works (almost) always with HFS paths (colon separated), you’re mixing up HFS and POSIX (slash separated) paths.
The parameter default location must be an alias specifier


#set tm_location to "/Users/bowjest/01 Level/03 Level/10 Level"
set tm_location to choose folder with prompt "TM folder :" default location "/Users/bowjest/01 Level/03 Level/10 Level"
#set glossary_location to "/Users/bowjest/01 Level/03 Level/11 Level"
set defaultLocation to (path to home folder as text) & "01 Level:03 Level:11 Level"
set glossary_location to POSIX path of (choose folder with prompt "Glossary folder :" default location alias defaultLocation)


Thanks, Stefan, I’ll give that a try.

I’ll need to wrap my head around the syntax, but I think I understand what you mean about the way to declare the variables/alias.

I appreciate your help.