call script from prompt

I have written some code that should in theory let the user choose which script to run from a selection of 3.

It opens a prompt takes the users input puts it through an if statment and runs which ever program was chossen.

But it doesnt work i always get the else dialog box.


--set theProgram to my thePrompt
set promptText to "Which script would you like to run: (to choose one pls type the number shown)" & return & return & "1: uploadFiles (from web pics)" & return & "2: uploadDetails (from web pics)" & return & "3: Check against file (from web pics)" & return
set promptOption to (display dialog promptText default answer 1 with icon 1)
set theProgram to text returned of promptOption

if theProgram is equal to 1 then
	
	tell application "uploadFiles"
		run
	end tell
	
else if theProgram is equal to 2 then
	
	tell application "uploadDetails"
		run
	end tell
	
else if theProgram is equal to 3 then
	
	tell application "chckTxtFile"
		run
	end tell
else
	display dialog "Your choice was invalid, sorry. Please try again"
	
end if

Can you see the problem, and if so can you help me please.

You can’t compare a string to an integer. Try this instead:

theProgram is equal to "1"...

Cheers!.. :wink: