X-Sharp / XSharpPublic

Public repository for the source code for the XSharp Compiler, Runtime, Project System and Tools.
Apache License 2.0
89 stars 36 forks source link

DBFMEMO/DBFBLOB: Incompatibilities with reading array from dbv file #1466

Closed cpyrgas closed 1 month ago

cpyrgas commented 1 month ago
  1. Reading an array from dbv is returned as OBJECT[] instead of ARRAY
  2. DATEs stored in the array are read as numbers

dbfmemo.zip

Attached dbf/dbv files where generated with this code in VO:

FUNCTION Start()  AS INT
LOCAL cFileName AS STRING
LOCAL a AS ARRAY

cFileName := "c:\test\rdd\dbfmemo"
a := { {1,"two",1.2} , {TRUE,FALSE,Today(),#TEST} } 

? DBCREATE(cFileName, {{"CFIELD","C",10,0},{"MFIELD","M",10,0}},,,,,,{"DBFMEMO"})

? DBUSEAREA(TRUE,,cFileName,,,,,,{"DBFMEMO"})
DBAPPEND()
FIELDPUT(1, "1")
FIELDPUT(2, A)
DBAPPEND()
FIELDPUT(1, "2")
FIELDPUT(2, {1,2,3})

DBCLOSEAREA()

reading the arrays from X#:

FUNCTION Start() AS VOID
    LOCAL cFileName AS STRING
    LOCAL blob AS USUAL
    LOCAL a,nested AS ARRAY

    cFileName := "c:\test\rdd\dbfmemo"
    a := { {1,"two",1.2} , {TRUE,FALSE,Today(),#TEST} } 

    ? DbUseArea(TRUE,,cFileName,,,,,,{"DBFMEMO"})

//  a := FieldGet(2) // cannot convert form OBJECT to ARRAY
    a := (OBJECT[]) FieldGet(2)
    nested := a[2]
    ? nested[3], ValType(nested[3]) // shows date as number

    ShowArray(a)

    DbSkip()

    a := (OBJECT[]) FieldGet(2) 
    ? ALen(a)
    ShowArray(a)

    DbCloseArea()
RobertvanderHulst commented 1 month ago

I have adjusted the runtime to return a real array and to convert the julian date to a real date.

cpyrgas commented 1 month ago

Confirmed fixed