xsharp.eu • FoxPro MEM file support in XSharp
Page 1 of 1

FoxPro MEM file support in XSharp

Posted: Mon Dec 06, 2021 12:57 pm
by jpmoschi
Good morning forum, continuing with the XSharp FoxPro compatibility check, in this case it is the "mem files" turn:
Unfortunately only the Char, Numeric, Logic and Date types are supported. VFPArrays, DateTimes, memo, currency and the other common Fox data types (from FoxBase to VFP9) are not supported and produce the error:.
Unknown type 'A' for memory variable 'TESTVARMEM'. Expected types are 'CDLN'
_StackTrace: " en XSharp.RT.MemReader.ReadFile(String cMask, Boolean lInclude)
en XSharp.RT.Functions._MRestore(String cFileName, Boolean lAdditive, String cSkel, Boolean lInclude)


It is an error that I am encountering on a recurring basis. FoxPro supports a greater variety of data types than the rest of the dialects at all levels

Best regards
Juan

FoxPro MEM file support in XSharp

Posted: Mon Dec 06, 2021 1:10 pm
by robert
Juan,
Thanks for reminding us. We need to indeed add support for restoring the other types from MEM files.
Unfortunately the .MEM file format additions by FoxPro are not documented, so we will need to 'hack' them.

Robert

FoxPro MEM file support in XSharp

Posted: Mon Dec 06, 2021 2:51 pm
by kevclark64
Considering that Foxpro MEM files are more like temporary files than permanent data, I don't think you need to be at all concerned whether XSharp MEM files are Foxpro compatible. As long as memory variables of whatever type can be saved from XSharp programs and then restored to XSharp programs, format compatibility with Foxpro doesn't seem particularly necessary.

FoxPro MEM file support in XSharp

Posted: Mon Dec 06, 2021 6:46 pm
by jpmoschi
I understand that it is less important than other topics but some of us want to know the real compatibility with FoxPro, to know where we stand. In my particular case the most important type non supported that I use in a "mem file" is the Array and in a few minutes I deduced the undocumented format after observing https://github.com/X-Sharp/XSharpPublic ... me/Runtime /XSharp.RT/Functions/MemVarSave.prg where the following comment is appreciated. Few changes need to be made

// Clipper type mem file, this has a diffent file format
// file format is as follows
// name, 11 bytes nul terminated (Clipper var name is 10 chars max)
// type, 1 byte ox80 ored with either "C", "N", "D" or "L" NEW A Array
// pad, 4 bytes
// len, 1 byte
// dec, 1 byte
// class, 1 byte not used
// pad, 13 bytes
// value, if C length is dec * 256 + len, null terminated NEW Array length like a N
// if N length is 8 bytes, real8 format
// for display - len = number of digits
// dec = number of decimal places
// if L length is 1
// if D length is 8, real8 format

// Clipper type mem file, this has a diffent file format
// file format is as follows
// name, 11 bytes nul terminated (Clipper var name is 10 chars max)
// type, 1 byte ox80 ored with either "C", "N", "D" or "L"
// pad, 4 bytes
// len, 1 byte
// dec, 1 byte
// class, 1 byte not used
// pad, 13 bytes
// value, if C length is dec * 256 + len, null terminated
// if N length is 8 bytes, real8 format
// for display - len = number of digits
// dec = number of decimal places
// if L length is 1
// if D length is 8, real8

// Array values ordered in secuence after the array declaraion

Obviously this functionality makes sense at runtime.
I even offer to do the mod but I guess nobody gets their hands on XSharp.RT for obvious reasons.

FoxPro MEM file support in XSharp

Posted: Mon Dec 06, 2021 8:08 pm
by robert
Juan,

Adding 'A' should be one thing. I think we also need to add Currency, Binary, Integer, DateTime etc.

Robert

FoxPro MEM file support in XSharp

Posted: Tue Dec 07, 2021 7:45 pm
by jpmoschi
Yes Robert, but for me those data types are not as used in "Mem Files" as they are in DbStruct () or DbCreate () array. There if there is an important lack of compatibility
best regard
Juan

FoxPro MEM file support in XSharp

Posted: Thu Dec 09, 2021 1:11 pm
by Karl-Heinz
Robert,

i created with VFP a mem file which is detected by X# as a Clipper mem file and therefore read via SELF:ReadClipperFile(wType). But when i save the content and reopen the mem file it´s being opened via SELF:ReadVOFile(wType), because the mem file structure has changed. However such a mem file can no longer be read by VFP. Is this behaviour by design ?

regards
Karl-Heinz

FoxPro MEM file support in XSharp

Posted: Thu Dec 09, 2021 2:35 pm
by robert
Karl-Heinz,

This is what Visual Objects did:
- it detected the type of MEM file when reading and allowed both 'old' and 'new' formats
- it was always writing in the new format.
No state (apart from the values of the variables) is kept between reading and writing. So how would the system know to write in the old format. The only situation would be where the file already exists. In that case the write code could detect the format from the existing file.

I can imagine an improvement in this area, but since most (VO) users did not use this at all (we were told ages ago to stop using PUBLIC and PRIVATE variables) we did not spend too much time in this area.
Now that we are supporting FoxPro as well it may be the right moment to revisit this code.

Robert

FoxPro MEM file support in XSharp

Posted: Tue Dec 21, 2021 7:48 pm
by jpmoschi
Good afternoon
I downloaded the Runtime project from GitHub, then I adaptedMemVarSave.prg https://github.com/X-Sharp/XSharpPublic/blob/main/Runtime/XSharp.RT/Functions/MemVarSave.prg to support the following VFP features:
1) 1 or 2 dimension arrays
2) variable names longer than 10 characters
Both changes maintain backwards compatibility.

I would love to know how to proceed to incorporate this change to the project obviously prior to the review of XSharp team and any member of the community

To complete it, it only remains to adapt MemVarSave.prg to create the .mem file. I consider this to have low priority over other issues raised
Best regards
Juan

FoxPro MEM file support in XSharp

Posted: Wed Dec 22, 2021 1:47 pm
by robert
Juan,
The normal procedure when working with Github is this:
- you clone our Repository
- you make the changes in your clone of the Repository and commit them
- you then create a "Pull Request" which is sent to us and asks us to pull the changes from your cloned repository into our repository
- we review the changes and when we accept them then they will be committed into our repository

If this is too much work or too complicated then you can also:
- you clone our Repository
- you make the changes in your clone of the Repository and commit them
- email us the changed code
- we will then review the code and will merge it into our repository

So since you have already made all the changes, I would like to ask you to email us the changed source code.

Robert