{iter vs. norm }
%include "edwin:specs.inc"        { basic edwin }

%begin

%string(20) infile
%integer colour =1
%integer count, offset, nop
%real xscale=1.0
%real yscale=1.0
%real minx = 0.0
%real maxx = 255.0
%real miny = 0;
%real maxy = 255.0

%routine do it(%integer offset)
  %integer i,px,py
  %real x,y, oldy

{axes}
  %if (count = 1) %then %start
     move abs(400,offset-20)
     line abs(400,offset+270)
     move abs(380,offset)
     line abs(940,offset)
     {ticks}
     move abs(400,offset+127)
     line abs(380,offset+127)
     move abs(400,offset+255)
     line abs(380,offset+255)
     move abs(655,offset)
     line abs(655,offset-20)
     move abs(910,offset)
     line abs(910,offset-20)
  %finish

  xscale = 256.0 / ( maxx - minx )
  yscale = 256.0 / ( maxy - miny )
  
  oldy= -1000.0
  %for i=1,1,nop %cycle
    read(x)
    read(y)
    px=intpt((x - minx)*2*xscale)+400
    py=intpt(( y - miny )*yscale)+offset
    %if (oldy> -999.0) %and (y> -999.0) %then line abs(px,py) %else move abs(px,py)
    oldy=y
   %repeat
%end
  
%on 9 %start
  terminate edwin
  newline
  %stop
%finish


  !produce a pdf file
  store on (1)
  open output(1,"drawfn.pdf")

  initialise for(defaultdevice)
  window(0,1400,0,1400)  
  new frame

{border}
!  move abs(350,0)   
!  line abs(350,1400)   
!  line abs(950,1400)
!  line abs(950,0)
!  line abs(350,0)   

  offset=50

    select input(0)
    prompt("nop: ")
    read(nop)
    prompt("min x: ")
    read(minx)
    prompt("max x: ")
    read(maxx)
    prompt("min y: ")
    read(miny)
    prompt("max y: ")
    read(maxy)
    prompt("input file name: ")
    read(infile)
    open input(2,infile)

  %for count=1,1,2 %cycle
  !file for reading
    select input(2)

    do it(offset)
%repeat

%endofprogram
