set a 2
set r1 20
set r2 20
set x1 50
set dx 0
set idx dx
set x2 67

number pow x y
{
   set val 1
   repeat c 0 y
   {
      set val (val*x/10)
   }
   //line 0 0 x val
   value val
}

//this is not very precise at all...
number root x y
{
   set c 10
   set val <pow c y>
   //is there a while loop in dbn?
   repeat d 0 60
   {
      smaller? val x
      {
         set c (c+1)
         set val <pow c y>
      }
   }
   value c
}

command drawLines
{
   paper 0
   pen 100

   //suggest where to click the mouse
   field 49 33 51 35 50

   repeat c 0 6
   {
      set y1 (a + <pow r1 c>)
      set y2 (a + <pow r2 c>)
      set x (x1 + dx*c)
      line x y1 x2 y2
   }
}

//line 10 10 <root 1000 3> 50

forever
{
   same? <mouse 3> 100
   {
      set dx ((<mouse 1> - 50) / 4)
      set r1 <root (<mouse 2> - 2) 4>
   }
   notsame? <mouse 3> 100
   {
      notsame? dx idx
      {
         smaller? dx idx
         {
            set dx (dx + 1)
         }
      }
      //check this twice to simulate "<" (rather than <=)
      notsame? dx idx
      {
         notsmaller? dx idx
         {
            set dx (dx -1)
         }
      }
      notsame? r1 20
      {
         smaller? r1 20
         {
            set r1 (r1 + 1)
         }
         notsmaller? r1 20
         {
            set r1 (r1 -1)
         }
      }
   }
   drawLines
}