X-Sharp / XSharpPublic

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

DBFMEMO: problem with BLOBImport() #1467

Closed cpyrgas closed 4 months ago

cpyrgas commented 4 months ago

A runtime error is thrown when trying to use BLOBImport(), see below. Same code works well in VO and only reading/exporting the file works fine in X# also.

FUNCTION Start() AS VOID
    LOCAL cFileName,cImage AS STRING
    cFileName := "c:\test\dbfmemo"
    cImage := "C:\Test\a.png" // substitute with any file

    ? RddSetDefault("DBFNTX")

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

    OpenFile(cFileName)
    ? DbAppend()
    FieldPut(1,"test")
    ? BLOBImport(2, cImage) // cannnot access dbf
    DbCloseArea()

    OpenFile(cFileName)
    ? FieldGet(1)
    ? BLOBExport(2, cImage + ".new", BLOB_EXPORT_OVERWRITE)
    DbCloseArea()

PROCEDURE OpenFile(cFileName AS STRING)
//  ? DbUseArea(TRUE,,cFileName,,,,,,{"DBFMEMO"}) // does not work in X# yet
    ? DbUseArea(TRUE,"DBFMEMO",cFileName) // not correct way
Description :   The process cannot access the file 'c:\test\rdd\dbfmemo.DBF' because it is being used by another process.
Subsystem : DBFMEMO
GenCode :   EG_READ Read error
SubCode :   1110 Read error
FuncSym :   BLOBImport
Severity :  ES_ERROR
Can Default :   True
Can Retry : False
Can Substitute :    False
FileName :  c:\test\rdd\dbfmemo.DBF
Stack Trace :   
 __ERROR:WINIOERROR (Line: 0)
 FILESTREAM:INIT (Line: 0)
 FILESTREAM:.CTOR (Line: 0)
 FILE:INTERNALREADALLBYTES (Line: 0)
 FLEXAREA:READBLOCKFROMFILE (Line: 0)
 FLEXAREA:READBLOCKFROMFILE (Line: 0)
 DBVMEMO:PUTVALUEFILE (Line: 0)
 DBFMEMO:PUTVALUEFILE (Line: 0)
 COREDB:<>C__DISPLAYCLASS51_0:<FILEPUT>B__0 (Line: 0)
 COREDB:DO (Line: 0)
 COREDB:FILEPUT (Line: 0)
 BLOBIMPORT (Line: 0)
 START (Line: 13)
RobertvanderHulst commented 4 months ago

There was a local variable name with the same name as a property in the RDD.

cpyrgas commented 4 months ago

Confirmed fixed