Welcome, Guest
Username: Password: Remember me
This public forum is meant for questions and discussions about Visual FoxPro
  • Page:
  • 1

TOPIC:

FoxPro MEM file support in XSharp 06 Dec 2021 13:57 #20705

  • jpmoschi
  • jpmoschi's Avatar
  • Topic Author


  • Posts: 76
  • 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

    Please Log in or Create an account to join the conversation.

    FoxPro MEM file support in XSharp 06 Dec 2021 14:10 #20707

    • robert
    • robert's Avatar


  • Posts: 3178
  • 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
    XSharp Development Team
    The Netherlands

    Please Log in or Create an account to join the conversation.

    FoxPro MEM file support in XSharp 06 Dec 2021 15:51 #20709

    • kevclark64
    • kevclark64's Avatar


  • Posts: 123
  • 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.

    Please Log in or Create an account to join the conversation.

    FoxPro MEM file support in XSharp 06 Dec 2021 19:46 #20711

    • jpmoschi
    • jpmoschi's Avatar
    • Topic Author


  • Posts: 76
  • 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 github.com/X-Sharp/XSharpPublic/blob/feature/Runtime/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.

    Please Log in or Create an account to join the conversation.

    FoxPro MEM file support in XSharp 06 Dec 2021 21:08 #20712

    • robert
    • robert's Avatar


  • Posts: 3178
  • Juan,

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

    Robert
    XSharp Development Team
    The Netherlands

    Please Log in or Create an account to join the conversation.

    FoxPro MEM file support in XSharp 07 Dec 2021 20:45 #20715

    • jpmoschi
    • jpmoschi's Avatar
    • Topic Author


  • Posts: 76
  • 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

    Please Log in or Create an account to join the conversation.

    FoxPro MEM file support in XSharp 09 Dec 2021 14:11 #20728

    • Karl-Heinz
    • Karl-Heinz's Avatar


  • Posts: 773
  • 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

    Please Log in or Create an account to join the conversation.

    FoxPro MEM file support in XSharp 09 Dec 2021 15:35 #20730

    • robert
    • robert's Avatar


  • Posts: 3178
  • 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
    XSharp Development Team
    The Netherlands

    Please Log in or Create an account to join the conversation.

    FoxPro MEM file support in XSharp 21 Dec 2021 20:48 #20855

    • jpmoschi
    • jpmoschi's Avatar
    • Topic Author


  • Posts: 76
  • Good afternoon
    I downloaded the Runtime project from GitHub, then I adapted MemVarSave.prg github.com/X-Sharp/XSharpPublic/blob/mai...ctions/MemVarSave.pr g 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

    Please Log in or Create an account to join the conversation.

    FoxPro MEM file support in XSharp 22 Dec 2021 14:47 #20857

    • robert
    • robert's Avatar


  • Posts: 3178
  • 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
    XSharp Development Team
    The Netherlands

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1