I do no see any kind of split function in AppleScript, am i missing something?
Today i picked up a book “ApppleScrpt Programming for the absolute beginner” because it was the only AppleScript book the book store had.
Looks like i should’ve driven to another store and got me a copy of AppleScript book from O’Reilly…
Ok, i must me missing something here, and could not figure out what.
My little test script works just fine:
on splitText(delimiter, someText)
set prevTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to delimiter
set lableName to first text item of someText
set catNumber to last text item of someText
set AppleScript's text item delimiters to prevTIDs
return lableName & catNumber
set myString to "Aroma, AROMA 046"
splitText(", ", myString)
display dialog lableName & tab & catNumber
this works, but when i add thise little splitText() subroutine to an iTunes sctipt and call splitText() later, i get an error:
In that script i have EXACT SAME subroutine and call it later in the script:
set myComment to comment of theTrack
if newLocation contains "[lable name]" then tell me to set newLocation to replaceText(newLocation, "[lable name]", lableName)
if newLocation contains "[cat number]" then tell me to set newLocation to replaceText(newLocation, "[cat number]", catNumber)
Script Utility Event Log shows this:
As you can see myComment variable gets passed to the splitText() correctly, but for the life of me i could not figure out why it does not work in this script,
but works fine on its own…