List to text

If I have a list of sentances and I isolate one into a single item list (e.g. {“I’m here”} rather than {“I’m not here”,“I’m here”,“I’m there”})How do I put it into a dialog? (eg “I’'m here”).

Model: iMac
AppleScript: 2.1.1
Browser: Safari 417.9.3
Operating System: Mac OS X (10.4)

set theList to {"I'm Here", "I'm not here"}

(* If you're sure 'theList' only contains one item *)
set theString to (theList as string)

(* To always get the first item in 'theList' *)
set theString to ((item 1 of theList) as string)

display dialog ("In case you didn't know, " & theString & ".")

You can use these three as well:


set theList to {"I'm Here", "I might be here later", "I'm not here"}
set theString to theList's beginning -- or first item, or item 1
display dialog ("In case you didn't know, " & theString & ".")
set theString to theList's middle item -- or second item, or item 2
display dialog ("In case you didn't know, " & theString & ".")
set theString to theList's end -- or last item, or item -1
display dialog ("In case you didn't know, " & theString & ".")

Yay, thanks guys! That biggining end middle thing might come in handy elswhere too! I’d done list to text before, but I threw that app off and couldent remember how.

Unfortunatly, it dosen’t work. This is what I DO have:

set rndquest to {"What is the meaning of life?", "What am I doing for goodness sake?", "If love is blind, why is lingerie so popular?", "When cheese gets its picture taken, what does it say?", "Do Lipton Tea employees take coffee breaks?", "What is Evian backwards?", "How come we drive on parkways, and park on driveways?", "why are asteroids in the hemisphere and hemoroids on your ass?", "How do women think?", "Is my mind made of curried mincmeat?"}
set questionsel to {}
			set randnum to random number from 0.5 to 10.5
			set randnum to round randnum
			set questionsel to (item randnum of list rndquest)
			set qsel to (questionsel as string)
			set Question to the text returned of (display dialog "Insert question" default answer questionsel buttons {"Add question", "Next"} default button "Next")

Fistoprince

You fail to mention anywhere what’s not working, and what exactly you’re trying to accomplish. Because we have no idea what you’re doing, we can’t tell you what to do to fix it.

When I run your code, I get an error. I’ll assume that that’s a problem. Change this line…

set questionsel to (item randnum of list rndquest)

…to …

set questionsel to (item randnum of rndquest)

Applescript already know’s it’s a list, so you don’t have to be so specific. Your code could be optimized in many ways, but here’s my version with a few obvious things moved cleaned up…

set rndquest to {"What is the meaning of life?", "What am I doing for goodness sake?", "If love is blind, why is lingerie so popular?", "When cheese gets its picture taken, what does it say?", "Do Lipton Tea employees take coffee breaks?", "What is Evian backwards?", "How come we drive on parkways, and park on driveways?", "why are asteroids in the hemisphere and hemoroids on your ass?", "How do women think?", "Is my mind made of curried mincmeat?"}
set questionsel to {}

set randnum to random number from 1 to (count rndquest)
set questionsel to (item randnum of rndquest) as string
set Question to the text returned of (display dialog "Insert question" default answer questionsel buttons {"Add question", "Next"} default button "Next")

j

Why not use some for randomness:

set rndquest to {"What is the meaning of life?", "What am I doing for goodness sake?"}

display dialog "Insert question" default answer (some item of rndquest) buttons {"Add Question", "Next"} default button "Next"
set question to the text returned of result

The some thing, I didn’t know. The word list in set questionsel to (item randnum of list rndquest) WAS what was messing it up. Thanks! I was building a quizz program that could store an infinite nuber of quizzes made by the user.