soccer calendar and classific

why it doesn’t work?

my startApp()

on startApp()
	set _primascelta to (choose from list {"Vedi calendario", "Classifica squadre", "Classifica marcatori"} with title "Serie A TIM")
	if _primascelta is "Vedi calendario" then
		open location "http://www.corrieredellosport.it/live/SerieA/calendario.shtml"
		set _secondascelta to (display dialog "Terminare il programma?" buttons {"No", "Annulla"} with title "Serie A TIM" default button 1)
		if _secondascelta is "No" then
		my startApp()
	end if
	if _primascelta is "Classifica" then
		open location "http://www.corrieredellosport.it/live/SerieA/classifica.shtml"
		set _secondascelta to (display dialog "Terminare il programma?" buttons {"No", "Annulla"} with title "Serie A TIM" default button 1)
		if _secondascelta is "No" then
		my startApp()
	end if
	if _primascelta is "Classifica marcatori" then
		open location "http://www.corrieredellosport.it/live/SerieA/statistiche/giocatori/gol.shtml"
		set _secondascelta to (display dialog "Terminare il programma?" buttons {"No", "Annulla"} with title "Serie A TIM" default button 1)
		if _secondascelta is "No" then
		my startApp()
	end if
end startApp

Hi LightSoul94,

That is not how to write ‘if’ statements in AppleScript. See AppleScriptLanguageGuide.pdf. Try starting with simple examples.

gl,
kel

For instance, you can not write this:

if _secondascelta is "No" then
       my startApp()

It has to be on the same line or end with ‘end if’

if _secondascelta is "No" then my startApp()

or

if _secondascelta is "No" then
       my startApp()
end if

gl,
kel

I think this is how you wanted it:

my startApp()

on startApp()
	try
		set _primascelta to (display dialog "Scegli un'opzione:" buttons {"Vedi calendario", "Classifica", "Annulla"} with title "Serie A TIM")
		if _primascelta is "Vedi calendario" then
			open location "http://www.corrieredellosport.it/live/SerieA/calendario.shtml"
			set _secondascelta to (display dialog "Terminare il programma?" buttons {"No", "Annulla"} with title "Serie A TIM" default button 1)
			if _secondascelta is "No" then
				my startApp()
			end if
		end if
		if _primascelta is "Classifica" then
			open location "http://www.corrieredellosport.it/live/SerieA/classifica.shtml"
			set _secondascelta to (display dialog "Terminare il programma?" buttons {"No", "Annulla"} with title "Serie A TIM" default button 1)
			if _secondascelta is "No" then
				my startApp()
			end if
		end if
		-- added the error trap
	on error _errMsg
		display dialog _errMsg
	end try
end startApp

gl,
kel

Hi,

due problemi (two problems)

choose from list returns boolean false or a list of items, so you have to flatten the list
display dialog returns a record. You need the button returned key

Instead of calling the handler again and again I wrote a repeat loop


startApp()

on startApp()
	repeat
		set _primascelta to (choose from list {"Vedi calendario", "Classifica squadre", "Classifica marcatori"} with title "Serie A TIM")
		if _primascelta is false then return
		set _primascelta to item 1 of _primascelta
		if _primascelta is "Vedi calendario" then
			open location "http://www.corrieredellosport.it/live/SerieA/calendario.shtml"
		else if _primascelta is "Classifica squadre" then
			open location "http://www.corrieredellosport.it/live/SerieA/classifica.shtml"
		else
			open location "http://www.corrieredellosport.it/live/SerieA/statistiche/giocatori/gol.shtml"
		end if
		set _secondascelta to button returned of (display dialog "Terminare il programma?" buttons {"No", "Annulla"} with title "Serie A TIM" default button 1)
		if _secondascelta is "Annulla" then return
	end repeat
end startApp

Hi Stefan,

Nice and tight! I would have gotten rid of the try block also after the script was running good.

Thanks,
kel

PS: As “Annulla” is the italian localized “Cancel” you can actually omit the line


 if _secondascelta is "Annulla" then return

because pressing “Cancel” aborts the script

Hi Stefan are you French?

I’m German living in Switzerland

Wow. the reason I ask this is that Stefan sounds French, but come to think of it, think I’ve asked you this before. Strange name for German. It’s amazing to me that I can be writing to people from all over the world. That’s part of what males this all fun. Meeting people from all over the world.

Edited: you know that living on a small island is very different.

Hi StefanK!
Thank you very much for helped me and thanks all who tried to help me :slight_smile:

Ps. i love Switzerland <3