%include "edwin:specs.inc"        { basic edwin }

%begin

%string(20) infile
%integer colour =1
%integer i, offset
%real yscale=1.0

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

{axes}
  move abs(400,offset-20)
  line abs(400,offset+270)
  move abs(380,offset)
  line abs(940,offset)

  
  oldy= -1000.0
  %for x=1,1,256 %cycle
    read(y)
    px=x*2+400
    py=intpt(y*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


  %for i=1,1,4 %cycle
  !file for reading
    prompt("yscale: ")
    select input(0)
    read(yscale)
    prompt("input file name: ")
    read(infile)
    open input(2,infile)
    select input(2)

    do it(offset)
    offset=offset+350
%repeat

%endofprogram
