Applescript to shell issues using osascript

Andrew Spitz's icon

I felt like I had this somewhat under control, but I have tried everything (from the forum, to trial and error, and google) and cannot get this particular one right. I would appreciate you help!

The usual " to get this " is not working in Osascript.

This is the script I need:

tell application "System Events"
    set MyList to (name of every process)
end tell
if (MyList contains "Spotify") is true then
    tell application "Spotify" to open location "spotify:track:THIS-NEED-TO-DYNAMIC"
end if

I'm fine if I hard code everything, but I need the part that says "THIS-NEED-TO-DYNAMIC" to change as needed. Sprintf is not being my friend (and all other ways).

Max Patch
Copy patch and select New From Clipboard in Max.

This feels like the closest:

In Luke's JS here: https://cycling74.com/forums/shell-problem-with-osascript-multiline It's all good (hard coded). It spits out with the line breaks (even into a message box?!), so thought I could recreate this by filling textedit using a separator, also ascii conversions to add a "return". But no luck.

Everything I try has issues. I don't understand why its not seeing my " as "

Thanks for any help!

7391's icon

Hello

Max Patch
Copy patch and select New From Clipboard in Max.

I'm not sure it responds to the question, but this one works with Spotify and a valid n° of track.
I'm using tap.applescript, do you use another objet to live applescript ?

Andrew Spitz's icon

Hey! Thanks for responding. This was a year and a half ago so luckily I had found a solution using [shell]

Max Patch
Copy patch and select New From Clipboard in Max.

Here is my version:

Cheers!