Skip to content

Instantly share code, notes, and snippets.

@dkeza
Last active November 14, 2016 08:20
Show Gist options
  • Save dkeza/347a50555c45220286dfcd5f77499773 to your computer and use it in GitHub Desktop.
Save dkeza/347a50555c45220286dfcd5f77499773 to your computer and use it in GitHub Desktop.
Test SebastiaanKlippert/go-foxpro-dbf Number, Datetime and Currency VisualFoxPro fields
CREATE TABLE testf (dtime t, number N(12), curr Y)
INSERT INTO testf (dtime, number, curr) VALUES (DATETIME(), 8027846523, 1234567890.1234)
RETURN .T.
package main
import (
"log"
"github.com/SebastiaanKlippert/go-foxpro-dbf"
)
func main() {
testnum, err := dbf.OpenFile("TESTF.DBF", new(dbf.Win1250Decoder))
if err != nil {
log.Fatal(err)
return
}
defer testnum.Close()
record, err := testnum.RecordAt(0)
if err != nil {
log.Fatal(err)
return
}
log.Println(record.Field(testnum.FieldPos("DTIME")))
log.Println(record.Field(testnum.FieldPos("NUMBER")))
CURR, _ := record.Field(testnum.FieldPos("CURR"))
log.Printf("%f\n", CURR)
}
@dkeza
Copy link
Author

dkeza commented Nov 14, 2016

testf.dbf table file for testing

(rename test.dbf.jpg to test.dbf)

testf dbf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment