# Will DynamicFileDriver work with xFiles and jFiles2?

**URL:** <https://clarionhub.com/t/will-dynamicfiledriver-work-with-xfiles-and-jfiles2/5336>\
**Category:** questions\
**Tags:** drivers, xfiles, json, xml\
**Created:** [August 5, 2022, 9:34am UTC](https://clarionhub.com/t/will-dynamicfiledriver-work-with-xfiles-and-jfiles2/5336 "2022-08-05T09:34:19Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Niels\_Larsen](https://clarionhub.com/user_avatar/clarionhub.com/niels_larsen/32/655_2.png) [@Niels\_Larsen](https://clarionhub.com/u/Niels_Larsen)\
**Post date:** [August 5, 2022, 9:34am UTC](https://clarionhub.com/t/will-dynamicfiledriver-work-with-xfiles-and-jfiles2/5336/1 "2022-08-05T09:34:19Z")

</div>

Hi

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

Regards Niels

---

<div class="post-metadata">

**Author:** ![Rick\_UpperPark](https://clarionhub.com/user_avatar/clarionhub.com/rick_upperpark/32/346_2.png) [@Rick\_UpperPark](https://clarionhub.com/u/Rick_UpperPark)\
**Post date:** [August 5, 2022, 1:46pm UTC](https://clarionhub.com/t/will-dynamicfiledriver-work-with-xfiles-and-jfiles2/5336/2 "2022-08-05T13:46:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Niels\_Larsen](https://clarionhub.com/user_avatar/clarionhub.com/niels_larsen/32/655_2.png) [@Niels\_Larsen](https://clarionhub.com/u/Niels_Larsen)\
**Post date:** [August 6, 2022, 6:05am UTC](https://clarionhub.com/t/will-dynamicfiledriver-work-with-xfiles-and-jfiles2/5336/3 "2022-08-06T06:05:57Z")

</div>

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

```

---

<div class="post-metadata">

**Author:** ![Bruce](https://clarionhub.com/letter_avatar_proxy/v4/letter/b/ccd318/32.png) [@Bruce](https://clarionhub.com/u/Bruce)\
**Post date:** [August 7, 2022, 7:45am UTC](https://clarionhub.com/t/will-dynamicfiledriver-work-with-xfiles-and-jfiles2/5336/4 "2022-08-07T07:45:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Niels\_Larsen](https://clarionhub.com/user_avatar/clarionhub.com/niels_larsen/32/655_2.png) [@Niels\_Larsen](https://clarionhub.com/u/Niels_Larsen)\
**Post date:** [August 8, 2022, 8:16am UTC](https://clarionhub.com/t/will-dynamicfiledriver-work-with-xfiles-and-jfiles2/5336/5 "2022-08-08T08:16:28Z")

</div>

> [@Bruce](#):
>
> myFile &= myDynFile.GetFileRef()  
> xml.trace(‘Status myFile=’ & STATUS(myFile))

```
Status myFile=0

```

> [@Bruce](#):
>
> myFile &= myDynFile.GetFileRef()  
> OPEN(myfile,42h)  
> xml.trace(‘After OPEN Errorcode=’ & errorcode() & ’ Error=’ & error() & ’ FileErrorCode=’ & fileErrorcode() & ’ fileError= ’ & fileError())  
> xml.trace(‘Status myFile=’ & STATUS(myFile))

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

```

---

<div class="post-metadata">

**Author:** ![Bruce](https://clarionhub.com/letter_avatar_proxy/v4/letter/b/ccd318/32.png) [@Bruce](https://clarionhub.com/u/Bruce)\
**Post date:** [August 8, 2022, 8:43am UTC](https://clarionhub.com/t/will-dynamicfiledriver-work-with-xfiles-and-jfiles2/5336/6 "2022-08-08T08:43:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Niels\_Larsen](https://clarionhub.com/user_avatar/clarionhub.com/niels_larsen/32/655_2.png) [@Niels\_Larsen](https://clarionhub.com/u/Niels_Larsen)\
**Post date:** [August 8, 2022, 8:54am UTC](https://clarionhub.com/t/will-dynamicfiledriver-work-with-xfiles-and-jfiles2/5336/7 "2022-08-08T08:54:54Z")

</div>

Thanks Bruce

Clarion: 11.0.0.13244  
DFD: 11.0.13244

---

<div class="post-metadata">

**Author:** ![Bruce](https://clarionhub.com/letter_avatar_proxy/v4/letter/b/ccd318/32.png) [@Bruce](https://clarionhub.com/u/Bruce)\
**Post date:** [August 8, 2022, 9:00am UTC](https://clarionhub.com/t/will-dynamicfiledriver-work-with-xfiles-and-jfiles2/5336/8 "2022-08-08T09:00:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Niels\_Larsen](https://clarionhub.com/user_avatar/clarionhub.com/niels_larsen/32/655_2.png) [@Niels\_Larsen](https://clarionhub.com/u/Niels_Larsen)\
**Post date:** [August 8, 2022, 9:32am UTC](https://clarionhub.com/t/will-dynamicfiledriver-work-with-xfiles-and-jfiles2/5336/9 "2022-08-08T09:32:24Z")

</div>

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>

```

---

<div class="post-metadata">

**Author:** ![Bruce](https://clarionhub.com/letter_avatar_proxy/v4/letter/b/ccd318/32.png) [@Bruce](https://clarionhub.com/u/Bruce)\
**Post date:** [August 8, 2022, 10:05am UTC](https://clarionhub.com/t/will-dynamicfiledriver-work-with-xfiles-and-jfiles2/5336/10 "2022-08-08T10:05:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Niels\_Larsen](https://clarionhub.com/user_avatar/clarionhub.com/niels_larsen/32/655_2.png) [@Niels\_Larsen](https://clarionhub.com/u/Niels_Larsen)\
**Post date:** [August 8, 2022, 10:10am UTC](https://clarionhub.com/t/will-dynamicfiledriver-work-with-xfiles-and-jfiles2/5336/11 "2022-08-08T10:10:59Z")

</div>

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

The Records(myFile) show zero.

---

<div class="post-metadata">

**Author:** ![Bruce](https://clarionhub.com/letter_avatar_proxy/v4/letter/b/ccd318/32.png) [@Bruce](https://clarionhub.com/u/Bruce)\
**Post date:** [August 10, 2022, 9:30am UTC](https://clarionhub.com/t/will-dynamicfiledriver-work-with-xfiles-and-jfiles2/5336/12 "2022-08-10T09:30:06Z")

</div>

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.
