 |
 |
Bug in AppleScript?
|
 |
|
 |
|
Grizzled Veteran
Join Date: Sep 2000
Location: Springfield, MA
Status:
Offline
|
|
I just found a an inconsistency between the results of a script run in "Script Editor" and a script run with osascript.
Here is a simple test case:
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">tell application "iTunes"
set curclass to class of current track as string
end tell
return curclass</pre><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">When I run this code in Script Editor, "audio CD track" is displayed in the script results window, as it should. However, when I run the code from the terminal, I get the following:
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">[pete@ligeia pete]$ osascript test.as
?lass cCDT?
[pete@ligeia pete]$ </pre><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">I already made an (ugly) workaround for this bug, but I'd like to see if anyone can reproduce, or explain this problem. I have the new AS update, but I have not tested this with the previous version.
|
|
We hope your rules and wisdom choke you / Now we are one in everlasting peace
-- Radiohead, Exit Music (for a film)
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Sep 2000
Location: Springfield, MA
Status:
Offline
|
|
One more thing, I have only seen this problem with casting the current track class type in iTunes to a string. For comparison, note that the following test case:
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">tell application "iTunes"
set curname to name of current track as string
end tell
return curname</pre><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">Works fine in both the Script Editor and the osascript command.
|
|
We hope your rules and wisdom choke you / Now we are one in everlasting peace
-- Radiohead, Exit Music (for a film)
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Oct 2000
Status:
Offline
|
|
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">quote:</font><hr /><font size="1" face="Geneva, Verdana, Arial, sans-serif">Originally posted by Mactoid:
<strong>One more thing, I have only seen this problem with casting the current track class type in iTunes to a string. For comparison, note that the following test case:
</font><blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">tell application "iTunes"
set curname to name of current track as string
end tell
return curname</pre><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">Works fine in both the Script Editor and the osascript command.</strong></font><hr /></blockquote><font size="1" face="Geneva, Verdana, Arial, sans-serif">Does osascript have its own AppleScript interpreter?
It seems that it's interpreting it as this:
tell application "iTunes"
set curclass to class of (current track as string)
end tell
But it cannot coerce a track to a string. Now what I assume you're trying to do is coerce the class of current track to a string. Which you could do by doing:
tell application "iTunes"
set curclass to (class of current track) as string
end tell
Where first you get current track's class, and then coerce that into a string as the result is simple enough to coerce.
Also the return seems a little useless no? Here's what I would use personally:
tell application "iTunes" to copy current track's class as string to curclass
If that fails...
tell application "iTunes" to copy (current track's class) as string to curclass
But it shouldn't fail <img border="0" title="" alt="[Wink]" src="wink.gif" />
|
|
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Sep 2000
Location: Springfield, MA
Status:
Offline
|
|
Yeah, that return was useless. Does AS automatically returns the last value assigned or something?
Anyway, thanks for the ideas, however all of the versions that you posted still resulted in the same problem from the osascript command <img border="0" title="" alt="[Frown]" src="frown.gif" />
|
|
We hope your rules and wisdom choke you / Now we are one in everlasting peace
-- Radiohead, Exit Music (for a film)
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|