weird applescript error in xcode

hello again,
i got the image thing working, but i have anoter error. another part of my app is that im going to tell the user what kind of iPod they have (generation, colour, etc), i have the code, and it works in applescript, but it doent in xcode


global oneGenIPod, twoGenIPod, threeGenIPod, fourGenIPod, u2grey, u2colour, u2s, Colour, fiveGBlack, fiveGWhite, fiveGs, oneGSil, oneGBlu, oneGPin, oneGGre, oneGGol, oneGMini, shuff, nanoWhite, nanoBlack, nanos, allPods
set oneGenIPod to {"M8513", "M8541", "M8697", "M8709"} --include in list
set twoGenIPod to {"M8737", "M8740", "M8738", "M8741"} --include in list
set threeGenIPod to {"M8976", "M8946", "M9460", "M9244", "M8948", "M9245"} --include in list
set fourGenIPod to {"M9282", "M9268"} --include in list
set u2grey to "M9787"
set u2colour to "MA127"
set u2s to {u2grey, u2colour} --include in list
set Colour to {"MA079", "M9829", "M9585", "M9586", "M9830"} --include in list
set fiveGWhite to {"MA002", "MA003"}
set fiveGBlack to {"MA146", "MA147"}
set fiveGs to {fiveGWhite, fiveGBlack} --include in list
set oneGSil to "M9160"
set oneGBlu to "M9436"
set oneGPin to "M9435"
set oneGGre to "M9434"
set oneGGol to "M9437"
set oneGMini to {oneGSil, oneGBlu, oneGPin, oneGGre, oneGGol} --include in list
set twoGSil to {"M9800", "M9801"}
set twoGBlu to {"M9802", "M9803"}
set twoGPin to {"M9804", "M0805"}
set twoGGre to {"M9806", "M9807"}
set twoGMini to {twoGSil, twoGBlu, twoGPin, twoGGre} --include in list
set shuff to {"M9724", "M9725", "MA133"} --include in list
set nanoWhite to {"MA350", "MA004", "MA005"}
set nanoBlack to {"MA352", "MA099", "MA107"}
set nanos to {nanoWhite, nanoBlack} --include in list
set allPods to {oneGenIPod, twoGenIPod, threeGenIPod, fourGenIPod, Colour, u2s, fiveGs, oneGMini, twoGMini, shuff, nanos}

set yourPod to choose folder
display dialog getPodType(yourPod)

on getPodGen(thePod)
	set prefs to ("Volumes:" & thePod & "iPod_Control:Device:SysInfo")
	set theSysInfo to open for access file prefs
	set theInfo to read theSysInfo
	set theStart to (offset of "ModelNumStr: " in theInfo) + 13
	set theEnd to theStart + 4
	set theGen to read theSysInfo from theStart to theEnd
	close access theSysInfo
	return theGen
end getPodGen

on getPodType(thePod)
	set theGen to getPodGen(thePod)
	if theGen is in item 1 of allPods then
		return "You are using a 1G iPod"
	else if theGen is in item 2 of allPods then
		return "You are using a 2G iPod"
	else if theGen is in item 3 of allPods then
		return "You are using a 3g iPod"
	else if theGen is in item 4 of allPods then
		return "You are using a 4G iPod"
	else if theGen is in item 5 of allPods then
		return "You are using a Colour/Photo iPod"
		--else if theGen is  in item 6 of allPods then
	else if theGen is in item 1 of item 6 of allPods then
		return "You are using a greyscale U2 iPod"
	else if theGen is in item 2 of item 6 of allPods then
		return "You are using colour U2 iPod"
		--end if
		--else if theGen is  in item 7 of allPods then
	else if theGen is in item 1 of item 7 of allPods then
		return "You are using a White 5G iPod"
	else if theGen is in item 2 of item 7 of allPods then
		return "You are using a Black 5G iPod"
		--end if
		--else if theGen is  in item 8 of allPods then
		--{oneGSil, oneGBlu, oneGPin, oneGGre, oneGGol}
	else if theGen is in item 1 of item 8 of allPods then
		return "You are using a Silver 1G iPod Mini"
	else if theGen is in item 2 of item 8 of allPods then
		return "You are using a Blue 1G iPod Mini"
	else if theGen is in item 3 of item 8 of allPods then
		return "You are using a Pink 1G iPod Mini"
	else if theGen is in item 4 of item 8 of allPods then
		return "You are using a Green 1G iPod Mini"
	else if theGen is in item 5 of item 8 of allPods then
		return "You are using a Gold 1G iPod Mini"
		--end if
		--else if theGen is  in item 9 of allPods then
		--{twoGSil, twoGBlu, twoGPin, twoGGre}
	else if theGen is in item 1 of item 9 of allPods then
		return "You are using a Silver 2G iPod Mini"
	else if theGen is in item 2 of item 9 of allPods then
		return "You are using a Blue 2G iPod Mini"
	else if theGen is in item 3 of item 9 of allPods then
		return "You are using a Pink 2G iPod Mini"
	else if theGen is in item 4 of item 9 of allPods then
		return "You are using a Green 2G iPod Mini"
		--end if
	else if theGen is in item 10 of allPods then
		--remember to ask if they want to store files anyways, even tho they can't read then
		return "You are using an iPod Shuffle"
		--else if theGen is  in item 11 of allPods then
	else if theGen is in item 1 of item 11 of allPods then
		return "You are using a White iPod Nano"
	else if theGen is in item 2 of item 11 of allPods then
		
		return "You are using a Black iPod Nano"
		--end if
	end if
end getPodType

once i put the code in xcode, and use the method to assign the iPod type to a text field, my app gives me an error (The variable allPods is not defined. (-2753)). if anyone has any ideas id appreciate any help.

thanks,
Z

Model: PowerBook G4
AppleScript: 1.10.3
Browser: Safari 417.8
Operating System: Mac OS X (10.4)

perfect!!! thanks a million

i have the same problem as above, except this time, i’m definining the variable in the handler, and its still giving me the error

global saveFolder, test, iPlay, yourPod, cur_song, cur_lyrics, oneGenIPod, twoGenIPod, threeGenIPod, fourGenIPod, u2grey, u2colour, u2s, Colour, fiveGBlack, fiveGWhite, fiveGs, oneGSil, oneGBlu, oneGPin, oneGGre, oneGGol, oneGMini, shuff, nanoWhite, nanoBlack, nanos, allPods
on launched theObject
	set saveFolder to ((path to documents folder) as text)
	set oneGenIPod to {"M8513", "M8541", "M8697", "M8709"} --include in list
	set twoGenIPod to {"M8737", "M8740", "M8738", "M8741"} --include in list
	set threeGenIPod to {"M8976", "M8946", "M9460", "M9244", "M8948", "M9245"} --include in list
	set fourGenIPod to {"M9282", "M9268"} --include in list
	set u2grey to "M9787"
	set u2colour to "MA127"
	set u2s to {u2grey, u2colour} --include in list
	set Colour to {"MA079", "M9829", "M9585", "M9586", "M9830"} --include in list
	set fiveGWhite to {"MA002", "MA003"}
	set fiveGBlack to {"MA146", "MA147"}
	set fiveGs to {fiveGWhite, fiveGBlack} --include in list
	set oneGSil to "M9160"
	set oneGBlu to "M9436"
	set oneGPin to "M9435"
	set oneGGre to "M9434"
	set oneGGol to "M9437"
	set oneGMini to {oneGSil, oneGBlu, oneGPin, oneGGre, oneGGol} --include in list
	set twoGSil to {"M9800", "M9801"}
	set twoGBlu to {"M9802", "M9803"}
	set twoGPin to {"M9804", "M0805"}
	set twoGGre to {"M9806", "M9807"}
	set twoGMini to {twoGSil, twoGBlu, twoGPin, twoGGre} --include in list
	set shuff to {"M9724", "M9725", "MA133"} --include in list
	set nanoWhite to {"MA350", "MA004", "MA005"}
	set nanoBlack to {"MA352", "MA099", "MA107"}
	set nanos to {nanoWhite, nanoBlack} --include in list
	set allPods to {oneGenIPod, twoGenIPod, threeGenIPod, fourGenIPod, Colour, u2s, fiveGs, oneGMini, twoGMini, shuff, nanos}
end launched

on awake from nib theObject
	--set test to saveFolder
	display dialog saveFolder
end awake from nib

this gives me the error: The variable saveFolder is not defined. (-2753)

thanks,
Z

Hi thePurpleTurtle,
I was wondering, would this be easier to manage compared to what you’re doing?:

property iPodList : {¬
	{name:"iPod", generations:{¬
		{name:"1G", models:{"M8513", "M8541", "M8697", "M8709"}}, ¬
		{name:"2G", models:{"M8737", "M8740", "M8738", "M8741"}}, ¬
		{name:"3G", models:{"M8976", "M8946", "M9460", "M9244", "M8948", "M9245"}}, ¬
		{name:"4G", models:{"M9282", "M9268"}}, ¬
		{name:"Colour/Photo", models:{"MA079", "M9829", "M9585", "M9586", "M9830"}}, ¬
		{name:"U2", versions:{¬
			{name:"greyscale", models:{"M9787"}}, ¬
			{name:"colour", models:{"MA127"}}}}, ¬
		{name:"5G", versions:{¬
			{name:"White", models:{"MA002", "MA003"}}, ¬
			{name:"Black", models:{"MA146", "MA147"}}}}}}, ¬
	{name:"iPod Mini", generations:{¬
		{name:"1G", versions:{¬
			{name:"Silver", models:{"M9160"}}, ¬
			{name:"Blue", models:{"M9436"}}, ¬
			{name:"Pink", models:{"M9435"}}, ¬
			{name:"Green", models:{"M9434"}}, ¬
			{name:"Gold", models:{"M9437"}}}}, ¬
		{name:"2G", versions:{¬
			{name:"Silver", models:{"M9800", "M9801"}}, ¬
			{name:"Blue", models:{"M9802", "M9803"}}, ¬
			{name:"Pink", models:{"M9804", "M0805"}}, ¬
			{name:"Green", models:{"M9806", "M9807"}}}}}}, ¬
	{name:"iPod Shuffle", models:{"M9724", "M9725", "MA133"}}, ¬
	{name:"iPod Nano", versions:{¬
		{name:"White", models:{"MA350", "MA004", "MA005"}}, ¬
		{name:"Black", models:{"MA352", "MA099", "MA107"}}}}}

set yourPod to choose folder
display dialog getPodType(yourPod)

on getPodModel(thePod)
	set thePath to ("Volumes:" & thePod & "iPod_Control:Device:SysInfo")
	set theSysInfo to open for access file thePath
	set theInfo to read theSysInfo
	close access theSysInfo
	tell (offset of "ModelNumStr: " in theInfo) + 13 to text (it as number) thru (it + 4) of theInfo
end getPodModel

on getPodType(thePod)
	set modelNumber to getPodModel(thePod)
	repeat with thisKind in iPodList
		repeat with thisGeneration in generations of (thisKind & {generations:{({name:null} & thisKind)}})
			repeat with thisVersion in versions of (thisGeneration & {versions:{({name:null} & thisGeneration)}})
				if modelNumber is in (contents of models of thisVersion) then
					set returnText to "You are using a "
					tell name of thisVersion to if it is not null then set returnText to returnText & it & space
					tell name of thisGeneration to if it is not null then set returnText to returnText & it & space
					return returnText & name of thisKind
				end if
			end repeat
		end repeat
	end repeat
	"You are using an unknown iPod type."
end getPodType

I’d wanted to try something out, but I don’t have that file on my iPod Shuffle (software v1.1.3).

What files do you have, Bruce? (Using ls -a)

wow…thats a big difference to mine lol…im pretty new to AS, havent done much in terms of applications, just a horde of mini scripts. thanks for the help, definately looks much more friendly than mine. hmm, i dont have an iPod shuffle handy to look at, but its good to know, maybe i can get my hands on a friend’s.
but i know that the shuffle doesnt have this file, according to a iPodLinux site i used originally:

here’s the site: http://ipodlinux.org/Generations#Finding_Your_Generation_in_SysInfo

Z

I assumed that shuff meant shuffle, as in this line here:

set shuff to {"M9724", "M9725", "MA133"} --include in list

I was wrong?

im not sure, it still gave me those serials on the site that i found them on, but according to most things i’ve looked at, the shuffle does not have a SysInfo file.
anyone have a shuffle that would be willing to take a peak thru the hidden files? Perhaps its hidden elsewhere?