Will DynamicFileDriver work with xFiles and jFiles2?

Hi

Will xFiles and jFiles2 work together with DynamicFileDriver so that it is possible to save dynamic data as XML/JSON?

Regards Niels

I don’t see why it wouldn’t. Use DynFile.GetFileRef() to get a reference to the file. Then pass that into the Load/Save methods of your jfiles/xfiles class.

That was my first thought too, but in xFiles I get an error:
52, Failed to open the Table () to read from(File System Error)

myDynFile   DynFile
myFile      &file   
!xml is declared elsewhere
    code

    myDynFile.SetName('MSFile') 
    myDynFile.SetDriver('MSSQL') 
    myDynFile.SetOwner('127.0.0.1,RainsWarehouse01,')
    
    if myDynFile.CreateFromSQL('SELECT TOP (1000) * FROM [RainsWarehouse01].[basic].[Currency]') <> 0
    else 
        myFile &= myDynFile.GetFileRef()
        if xml.Save(myFile,'test.xml')
            Message(xml.ErrorStr)
        end
    end

It should work fine.

Error 52 is “File already Open”. But xFiles only tried to open a table if STATUS(table) returns 0.

So, to debug this, I recommend 2 experiments;

myFile &= myDynFile.GetFileRef()
xml.trace(‘Status myFile=’ & STATUS(myFile))

also
myFile &= myDynFile.GetFileRef()
OPEN(myfile,42h)
xml.trace(‘After OPEN Errorcode=’ & errorcode() & ’ Error=’ & error() & ’ FileErrorCode=’ & fileErrorcode() & ’ fileError= ’ & fileError())
xml.trace(‘Status myFile=’ & STATUS(myFile))

The debugging will appear in Debugview++ - Post the results here.

Cheers
Bruce

Status myFile=0
After OPEN Errorcode=52 Error=File Already Open FileErrorCode= fileError=
Status myFile=0

ok, so there’s a bug in the DFD. Please let me know which build of Clarion you are using, and which build of DFD, and I’ll post a PTSS about it.

Status should not return 0 if the file is open. From the help on STATUS -

The STATUS procedure returns zero (0) if the file is not open, and the file’s access mode if it is open. If the access mode is actually zero (Read Only / Any Access), 40h (Read Only / Deny None) is returned (see OPEN)."

In the meantime I’ll see about making an xFiles release that works around this.

Thanks Bruce

Clarion: 11.0.0.13244
DFD: 11.0.13244

I’ve made a build 3.26 for xFiles which should work around the problem. Grab that and let me know.

I posted a PTSS # 43345

Now I have tried 3.26 and there are no errors from xFiles, but there are no records either.
The file looks like this:

<?xml version="1.0" encoding="ISO-8859-1"?>
<records>
</records>

ok, so do a simple loop in your code to see if there are any records in the file.

myFile &= myDynFile.GetFileRef()
OPEN(myfile,42h)
xml.trace('Records = ’ & Records(myFile))
Set(myFile)
Loop
Next(myFile)
If Errorcode() then break.
xml.trace(‘found record’)
End

cheers
Bruce

0 records but if I remove the set(myFile) I get 10 records as expected in the loop.

The Records(myFile) show zero.

ok, I’ll see about doing something that’ll bypass the SET and only use NEXT. Obviously the DFD in this particular setup isn’t operating as a “normal” table.