Sidebar

Home



Knowledge Base


Guides & Tutorials

Projects

Samples

  G-Code
   Square
   Arcs
   Mickey
   Arrow
   Bear
   Ball In Cage

  Dialogs
   Square
   Rounded Square
   Guess The Number

  O-Words
   Polygon

  Subprocedures
   Lissajous

   Lissajous (sub..endsub..call)
   Lissajous (call..sub..endsub)

   Lissajous (exec..O..M99)

   Lissajous (G65)
   Lissajous (G65 with GOTO)

   Palindrome
   PrimeFactors
   Fibonacci

  Splines
   Butterfly

  G06
   arrchr

  Dynamic
   Clock
   DateTime

  Notepad++ Plugin
   Examples


kb:samples:guess_the_number

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	
kb/samples/guess_the_number.txt · Last modified: 2024/04/02 23:02 by 127.0.0.1

Page Tools