Loading a DATASET with a Record Structure
Hi,
I was having to flatten a complex data structure and realised a structure in a DATASET would be easy to use. I reproduce below as it may be of general use. (I just used it for my specific task, Richard Taylor has generalised by wrapping it inside a FUNCTIONMACRO)
Running the above gives:

I was having to flatten a complex data structure and realised a structure in a DATASET would be easy to use. I reproduce below as it may be of general use. (I just used it for my specific task, Richard Taylor has generalised by wrapping it inside a FUNCTIONMACRO)
- Code: Select all
//************************************************************************
RecordStructureAsDATASET(RecStruct) := FUNCTIONMACRO
#DECLARE(xmlOfRecordStructure)
#EXPORT(xmlOfRecordStructure,RecStruct)
RRec := RECORD
STRING ecltype := XMLTEXT('@ecltype');
BOOLEAN isRecord := (BOOLEAN) XMLTEXT('@isRecord');
STRING label := XMLTEXT('@label');
STRING name := XMLTEXT('@name');
STRING position := XMLTEXT('@position');
STRING rawtype := XMLTEXT('@rawtype');
STRING size := XMLTEXT('@size');
STRING ttype := XMLTEXT('@type');
BOOLEAN isEnd := (BOOLEAN) XMLTEXT('@isEnd');
END;
OnRec := {STRING FldEntry};
RETURN PARSE(DATASET([{%'xmlOfRecordStructure'%}],OnRec),FldEntry,RRec,XML('Data/Field'));
ENDMACRO;
//************************************************************************
R1abc := RECORD
UNSIGNED1 u1;
STRING2 s2;
SET OF STRING3 ss3;
END;
R2def := RECORD
REAL4 r4;
UDECIMAL3_2 ud32;
R1abc;
R1abc InnerR1;
END;
R := RECORD
BOOLEAN b;
QSTRING5 qs5;
DATASET(R1abc) dsr1;
SET OF DATASET(R2def) sdsr2;
END;
OUTPUT(RecordStructureAsDATASET(R),NAMED('RecordStructureAsDATASET'));
Running the above gives:

- Allan
- Posts: 444
- Joined: Sat Oct 01, 2011 7:26 pm
1 post
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest