Guess The Number

(name,Guess Number)
 
(dlgname,Guess Number, opt=1)
(dlg,Guess number between 1 and 10, typ=label, x=20, w=280, color=0xffa500)
(dlg,Press OK to begin, typ=label, x=120, w=150, color=0xffa500)
(dlgshow)
 
#<guess> = [round[rand[] * 9] + 1]
#<guess_my> = 5
#<guess_cnt> = 0
 
O<loop> repeat[10]
 
  #<guess_cnt> = [#<guess_cnt> + 1]
 
  (dlgname,Guess Number)
  (dlg,Guess number between 1 and 10, typ=label, x=20, w=280, color=0xffa500)
  (dlg,Number of tries: #<guess_cnt,0>, typ=label, x=20, w=280)
  (dlg,Number, x=0, dec=0, def=guess_my, min=1, max=10, param=guess_my)
  (dlg,Press OK to continue, typ=label, x=120, w=170, color=0xffa500)
  (dlgshow)
 
  o<chk> if[#<guess_my> GT #<guess>]
	(dlgname,Guess Number, opt=1)
	(dlg,Your number is too high, typ=label, x=20, w=280, color=0xffa500)
	(dlgshow)
  o<chk> elseif[#<guess_my> LT #<guess>]
	(dlgname,Guess Number, opt=1)
	(dlg,Your number is too low, typ=label, x=20, w=280, color=0xffa500)
	(dlgshow)
  o<chk> else
	(dlgname,Guess Number, opt=1)
	(dlg,Congratulation!, typ=label, x=20, w=320, color=0xffa500)
	(dlg,You guessed correct number in #<guess_cnt,0> tries, typ=label, x=20, w=320)
	(dlgshow)
	M2
  o<chk> endif
 
O<loop> endrepeat
 
(dlgname,Guess Number)
(dlg,You failed to guess correct number, typ=label, x=20, w=280, color=0xffa500)
(dlgshow)
 
M2