• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Simple "value Class" problem that`s driving me crazy
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Simple "value Class" problem that`s driving me crazy


  • Subject: Re: Simple "value Class" problem that`s driving me crazy
  • From: Walter Ian Kaye <email@hidden>
  • Date: Sun, 4 Jan 2004 20:00:55 -0800

At 12:22p +1000 01/05/2004, Bruce didst inscribe upon an electronic papyrus:

-Hello everyone. My name is Bruce and I am fairly new to AppleScript and this is my first time posting to this user list, so please forgive me if I don`t follow the correct procedures.

Welcome. My head is leaning to the `left` for some reason... ;->

--1)
set FilePath to "Main:SongFolder:"
-- Here I am setting the FilePath (the folder "SongFolder" on the disc "Main") to the folder holding my song

So far so good.

which for testing purposes I will call "TestSong" (without the quotations of course.)

--2)
set DialogBox to display dialog "My Selection" default answer "" buttons {"OK"} default button "OK"
--This is a crude dialog window into wich I enter my song`s name.
set SelectedSong to text returned of DialogBox

Still good.

--3)
tell application "iTunes"
play FilePath & SelectedSong
end tell
---------------------------------------------------------
-- This seems so basic and yet it doesn`t work. (That`s what`s driving me crazy.) You get an error message that says "AppleScript Error. iTunes got an error: Can`t make some data into the expected type. (That`s why I feel it has something to do with value classes.) However, if I add the following before the tell application command, it works fine:

--2.5)
if SelectedSong is "TestSong" then
set SelectedSong to "TestSong"
end if

-- This seems soooo redundant, and yet it works. Why?

Looks like it's being held on to as a reference to the dialog box.
Dunno why finicky, but that would seem to be the explanation.

Is there a simple command like "set SelectedSong to SelectedSong of string" that I could do once to make it work no matter what song I inputed? By the way, that "set...of string" command doesn`t work. It was only an idea.

Well you're close. Instead of "of" use "as":

set SelectedSong to SelectedSong as string

Or beforehand:

set SelectedSong to text returned of DialogBox as string

Or this should do the trick, too:

copy text returned of DialogBox to SelectedSong


-boo
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

References: 
 >Simple "value Class" problem that`s driving me crazy (From: Bruce <email@hidden>)

  • Prev by Date: Simple "value Class" problem that`s driving me crazy
  • Next by Date: Re: Simple "value Class" problem that`s driving me crazy
  • Previous by thread: Simple "value Class" problem that`s driving me crazy
  • Next by thread: Re: Simple "value Class" problem that`s driving me crazy
  • Index(es):
    • Date
    • Thread