From 37da2899f40661e3e9631e497da8dc59b971cbd0 Mon Sep 17 00:00:00 2001 From: "Charles.Forsyth" Date: Fri, 22 Dec 2006 17:07:39 +0000 Subject: 20060303a --- appl/math/hist0.b | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 appl/math/hist0.b (limited to 'appl/math/hist0.b') diff --git a/appl/math/hist0.b b/appl/math/hist0.b new file mode 100644 index 00000000..0484c98b --- /dev/null +++ b/appl/math/hist0.b @@ -0,0 +1,99 @@ +implement Hist0; + +include "sys.m"; + sys: Sys; + print: import sys; +include "math.m"; + math: Math; + fmin: import math; + +include "draw.m"; +include "tk.m"; + tk: Tk; + +include "bufio.m"; + bufio: Bufio; + Iobuf: import bufio; + +include "gr.m"; + gr: GR; + Plot: import gr; + +Hist0: module{ + init: fn(nil: ref Draw->Context, argv: list of string); +}; + + +plotfile(ctxt: ref Draw->Context, nil: list of string, filename: string){ + p := gr->open(ctxt,filename); + input := bufio->open(filename,bufio->OREAD); + if(input==nil){ + print("can't read %s",filename); + exit; + } + + n := 0; + maxn := 100; + x := array[maxn] of real; + y := array[maxn] of real; + while(1){ + xn := input.gett(" \t\n\r"); + if(xn==nil) + break; + yn := input.gett(" \t\n\r"); + if(yn==nil){ + print("after reading %d pairs, saw singleton\n",n); + exit; + } + if(n>=maxn){ + maxn *= 2; + newx := array[maxn] of real; + newy := array[maxn] of real; + for(i:=0; iContext, argv: list of string){ + sys = load Sys Sys->PATH; + math = load Math Math->PATH; + tk = load Tk Tk->PATH; + bufio = load Bufio Bufio->PATH; + if((gr = load GR GR->PATH) == nil){ + sys->print("%s: Can't load gr\n",hd argv); + exit; + } + + tkargs := ""; + argv = tl argv; + if(argv != nil) { + tkargs = hd argv; + argv = tl argv; + } + if(argv!=nil) + plotfile(ctxt,argv,hd argv); +} -- cgit v1.2.3