Just a question

Joined
Feb 12, 2012
Messages
2
Reaction score
0
Points
1
Please check the stats part of this is not working
Code:
repeat
	set statswin to 0
	set statsLoser to 0
	set statsplays to 0
	set x to some item of "1234556789" as number
	display dialog "Guess a number between 1 and 9" default answer "Insert number here" buttons {"OK", "Stats"} default button 1
	if the button returned of the result is "Stats" then
		display dialog "wins " & statswin
		display dialog "Loses " & statsLoser
		display dialog "Total games " & statsplays
	else
		
		try
			set theAnswer to (text returned of result) as number
		on error
			display dialog "Invalid Input"
			say "Invalid input"
			return
		end try
		
		--Test for Correct Numbers
		if theAnswer < 1 or theAnswer > 10 then
			set theTest to 0
		else
			set theTest to 1
		end if
		
		--Return Comments to user
		if theTest = 0 then
			display dialog "Invalid Input"
		else
			set m to theAnswer * x
			set a to 1
			if m is in {1, 4, 9, 16, 25, 36, 49, 64, 81} then
				set a to 2
			end if
			if a is equal to 2 then
				
				display dialog "winner"
				set statswin to statswin + 1
				set statsplays to statsplays + 1
			else
				display dialog "loser"
				set statsLoser to statsLoser + 1
				set statsplays to statsplays + 1
			end if
		end if
	end if
end repeat
end
end
 

chscag

Well-known member
Staff member
Admin
Joined
Jan 23, 2008
Messages
65,248
Reaction score
1,833
Points
113
Location
Keller, Texas
Your Mac's Specs
2017 27" iMac, 10.5" iPad Pro, iPhone 8, iPhone 11, iPhone 12 Mini, Numerous iPods, Monterey
Your post has been moved to the proper forum. It does not belong in "Community Suggestions........."
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top