Re: HELP with 'seek'
- Posted by Jim <futures8 at PCOLA.GULF.NET> Aug 20, 2000
- 517 views
Irv, Again, Thanks. Lots of interesting stuff for me to study here. I like your assignment of field numbers as constants. Make following the code a lot clearer. Regards, Jim Duffy Irv Mullins wrote: > On Fri, 18 Aug 2000, I sent the backup version of the file. > Let's try again with the _current_ one :) > > -- Am I reading your code correctly, you're only using the last three records? > -- fI so, the following should work > > without warning > include get.e > > constant DATE = 1, OPEN1 = 2, HIGH1 = 3, LOW1 = 4, > CLOSE1 = 5, VOLUME1 = 6, OPENINT1 = 7 > > atom DayRange1, UpperShadow1, LowerShadow1 > > object data, line > atom fn > > function readline() > object line, item > line = {} > for i = DATE to OPENINT1 do > item = get(fn) > if item[1] = GET_SUCCESS then > line = append(line,item[2]) > else return -1 > end if > end for > return line > end function > > fn = open("testdata.txt","r") > data = {} > while 1 do > line = readline() > if atom(line) then exit > else data = append(data,line) > end if > end while > close(fn) > > printf(1,"%d records read\n",length(data)) > > for i = 1 to length(data) do > printf(1,"Date: %s\n",{data[i][DATE]}) > for j = OPEN1 to OPENINT1 do > data[i][j] = value(data[i][j]) > data[i][j] = data[i][j][2] > end for > end for > > -- discard all but last 3 records; > data = data[length(data)-3..length(data)] > > clear_screen() > puts(1,"Last 3 days\n") > puts(1,"Date Open High Low Close Volume OpenInt\n") > for i = 1 to length(data) do > printf(1,"%s %4.5f %4.5f %4.5f %8d %8d \n",data[i]) > end for