aUCBLogo Demos and Tests / textmodevalues
			
				
			
			to textmodevalues
   setCaseIgnored false
   clearText
   for [i 1 3][setCursor list 79 i]
   overwritemode
   setUpdateGraph false
   init_boxes
   angle=90
   length=200
   number=4
   factor=1
   x=0
   y=0
   drawlines
   intbox [angle a 5 1 12]
   intbox [length l 20 1 13]
   intbox [number n 35 1 13]
   floatbox [factor f 50 1 15 1.001] 
   intbox [x x 5 3 12]
   intbox [y y 20 3 12]
   setCursor list 0 5
   pr [Click with the mouse on the values to change them!]
   run_boxes [drawlines]
end
to init_boxes
   intboxes=[]
   floatboxes=[]
   activebox=-1
   focusbox=1
end
to drawlines
   cs ht pu setxy -length/2+x -length/2+y pd
   if number < 1 [number=1 display intboxes.3]
   drawit number length
   updateGraph
end
to drawit n l
   if n==0 [stop]
   setPC hsb 360*n/number 1 1
   fd l right angle
   drawit n-1 l*factor
end
to display intboxlist
   local [display_name display_x display_y]
   display_name=intboxlist.1
   display_x=intboxlist.3
   display_y=intboxlist.4
   setCursor list display_x display_y
   type str intboxlist.5 "\ 
   setCursor list display_x display_y
   (type display_name "\  thing display_name)
   wait 0
end
to str num ch
   if num==0 [output "]
   output word ch str num-1 ch
end
to intbox intboxlist   ;intboxlist is: [name key x y sizex]
   display intboxlist
   push "intboxes intboxlist
end
to floatbox floatboxlist   ;floatboxlist is: [name key x y sizex factor]
   display floatboxlist
   push "floatboxes floatboxlist
end
to inputbox boxlist boxnumber
   local [inputbox_]
   inputbox_=boxlist.boxnumber
   setCursor list inputbox_.3 inputbox_.4
   type str inputbox_.5 "\ 
   setCursor list inputbox_.3 inputbox_.4
   (type inputbox_.1 "\ )
   wait 0
   local [ch w]
   w="
   do_until
   [   ch=readChar
      ifelse (or number? ch  ch==".  ch=="-)
      [   type ch
         wait 0
         w=word w ch
      ][   ifelse ch==char 8
         [   if (count w) > 0 [w=butLast w]
            setCursor list inputbox_.3 inputbox_.4
            type str inputbox_.5 "\ 
            setCursor list inputbox_.3 inputbox_.4
            (type inputbox_.1 "\  w)
            wait 0
         ][   tone 0 100
         ]
      ]
   ][or ch==char 13 ch==char 27]   
   make inputbox_.1 w
end
to run_boxes updateproc
   local [run_boxes_x run_boxes_y newactive run_boxex_c boxkey]
   disableTextMouseEvents
   run_boxes_x=TextMouseX
   run_boxes_y=TextMouseY
updateVars
   newactive=[]
   ifelse MouseButtons != 0
   [   foreach intboxes
      [   if (and run_boxes_y==(?).4  
               run_boxes_x >= (?).3  
               run_boxes_x < (?).3+(?).5)
         [   if MouseButtons==1
            [   make (?).1 (thing (?).1)+1
            ]
            if MouseButtons==2
            [   make (?).1 (thing (?).1)-1
            ]
            display ?
            newactive=#
            focusbox=#
         ]
      ]
      foreach floatboxes
      [   if (and run_boxes_y==(?).4  
               run_boxes_x >= (?).3  
               run_boxes_x < (?).3+(?).5)
         [   if MouseButtons==1
            [   make (?).1 (thing (?).1)*(?).6
            ]
            if MouseButtons==2
            [   make (?).1 (thing (?).1)/(?).6
            ]
            display ?
            newactive=#+1000
            focusbox=#
         ]
      ]
      run updateproc
      if activebox != newactive [waitms 300 activebox=newactive]
   ][   activebox=-1
   ]
   if key? 
   [   run_boxex_c=readChar
      if run_boxex_c==char 27 [enableTextMouseEvents stop]
      boxkey=false
      foreach intboxes
      [   if (?).2==run_boxex_c
         [   boxkey=true
            focusbox=#
            make (?).1 (thing (?).1)-1
            display ?
            run updateproc
         ]
         if (upperCase (?).2)==run_boxex_c
         [   boxkey=true
            focusbox=#
            make (?).1 (thing (?).1)+1
            display ?
            run updateproc
         ]
      ]
      foreach floatboxes
      [   if (?).2==run_boxex_c
         [   boxkey=true
            focusbox=#
            make (?).1 (thing (?).1)/(?).6
            display ?
            run updateproc
         ]
         if (upperCase (?).2)==run_boxex_c
         [   boxkey=true
            focusbox=#
            make (?).1 (thing (?).1)*(?).6
            display ?
            run updateproc
         ]
      ]
      if not boxkey
      [   ifelse focusbox < 1000 
         [   inputbox intboxes focusbox   
         ][   inputbox floatboxes focusbox   
         ]
         run updateproc
      ]
   ]
   GC
   run_boxes updateproc
end