Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / pas2js / 2019-12

anonymous record type

2 messages · 1 person · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

warleyalex

There are cross units to smart mobile.
http://blog.synopse.info/post/2014/08/11/CrossPlatform-Clients/SmartMobileStudio

Now, I'm translating some cross-Platform mORMot Clients to pas2js. The first draft is shown at https://www.youtube.com/watch?v=mitrHJIJUQ0

We should use the record type to store/retrieve the JSON data. One thing I could find a way is to populate this complex JSON object, like this:

{
"RowID" : 1,
"FirstName" : "First1",
"LastName" : "Last1",
"Data" : null,
"YearOfBirth" : 1801,
"YearOfDeath" : 1826,
"Another" : 1,
"Sexe" : 0,
"Simple" : {
"F" : "",
"G" : [],
"H" : {
"H1" : 0,
"H2" : "",
"H3" : {
"H3a" : false,
"H3b" : null
}
},
"I" : "",
"J" : []
}
}

this json would be mapped to this record type structure:

type // define some enumeration types, used below
  TPeopleSexe = (sFemale, sMale);
  TRecordEnum = (reOne, reTwo, reLast);
type // define some record types, used as properties below
  TSimpleJSONArray = record
    F: String;
    G: array of String;
    H: record
      H1: Integer;
      H2: String;
      H3: record
        H3a: Boolean;
        H3b: TSQLRawBlob;
      end;
    end;
    I: TDateTime;
    J: array of record
      J1: Byte;
      J2: TGUID;
      J3: TRecordEnum;
    end;
  end;

hum,I'm stuck, anonymous record type not yet implemented in pas2js. In order to perform
to use CRUD/ORM remote access we need anonymous record in some way.

One other minor thing is "enum const" - status: not yet implemented for instance:

  TSQLFieldBit = enum (Low = 0, High = 255);
  TSQLFieldBits = set of TSQLFieldBit;

Reply by email

warleyalex
to warleyalex

I've converted some partial mORMot client cross platform units to pas2js in the past, but unfortunately I could not finish them because of the missing "anonymous record" feature. I remember the Delphi server is compiled in both FPC and windows as well. The CRUD part is missing, because of that pas2js missing feature.

See at
https://blog.synopse.info/?post/2014/08/11/CrossPlatform-Clients/SmartMobileStudio

This feature is important, because delphi server, will generates automatically pas2js client units when the server have some CRUD, and complex record structures is expected to work. We should use the record type to store/retrieve the JSON data. For instance, the following JSON would be mapped to anonnymous record type structure.

{
"RowID" : 1,
"FirstName" : "First1",
"LastName" : "Last1",
"Data" : null,
"YearOfBirth" : 1801,
"YearOfDeath" : 1826,
"Another" : 1,
"Sexe" : 0,
"Simple" : {
"F" : "",
"G" : [],
"H" : {
"H1" : 0,
"H2" : "",
"H3" : {
"H3a" : false,
"H3b" : null
}
},
"I" : "",
"J" : []
}
}

Reply by email