puts stdout "starting test"

source hli.tcl

cfmini status
if { $status != [HSUCC] } { puts stdout "failed init $status" }
if { [file exists new.db] } { exec rm new.db }

set data {15 16 12 25 31 45 62}

set db [fameopen "new.db" [HCMODE]]
if { $db < 0 } { puts stdout "failed open" }

set test t1
cfmnwob status $db test [HSERIE] [HDAILY] [HNUMRC] [HBSDAY] [HOBBEG]
if { $status != [HSUCC] } { puts stdout "error $status creating object $test" }
if [catch {famewrite $db $test 1990 1 $data}] {
  puts stderr "Error writing data"
}

set info [famegetinfo $db $test]

if [catch {set data2 [fameread $db $test [lindex $info 5] [lindex $info 6] \
                              [lindex $info 7] [lindex $info 8] ] } res ] {
  puts stderr "Error reading data $res"
  set data2 ""
} else { puts "Write/Read test OK" }

fameclose $db
famestop
exec /bin/rm new.db

button .quit -text "Quit" -command "destroy ."
listbox .list
foreach i $data { .list insert end $i }
pack .list
pack .quit
