Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…
Cannot retrieve contributors at this time
63 lines (63 sloc) 3.5 KB
// Macro to reconstitute an original matrix from a NumericField-formatted
// dataset. In the simplest case, the assumption is that the field order
// of the resulting table is in line with the field numbers in the input
// dataset, with the ID field as the first field. If a field mapping is
// specified, this order can be re-arranged.
// dIn : The name of the input dataset in NumericField format
// lOut : The name of the resulting layout the data should be in
// dOut : The name of the resulting dataset
// dMap : [OPTIONAL] If the user customized the fields used in the ToField
// process, they should include the mapping table that was created
// automatically by ToField here so the fields map back properly.
// This will be named NF_map, where NF is the name of the
// NumericField table that was created by ToField.
// Examples (used to reconstitute the ToField examples):
// ML.FromField(dMatrix,lOrig,dResults);
// ML.FromField(dMatrix,lOrig,dResults,dOrigData_Map);
// IMPORTANT NOTE: If fields in lOut were disregarded by the ToField macro
// during the creation of the NumericField table, those fields WILL NOT be
// reconstituted by this macro. They will be left blank or zero.
EXPORT FromField(dIn,lOut,dOut,dMap=''):=MACRO
// If a mapping table was specified, we need to join it to the input data
// to marry the field number to the field name.
%dInPrep%:=TABLE(dIn,{UNSIGNED %id%:=id;dIn;});
// Variable to keep track of which field number we are on
#DECLARE(iUnPivotLoop) #SET(iUnPivotLoop,0)
// Variable to hold a string that will #EXPAND to a set of field assignments
// used when DENORMALIZE is called.
#DECLARE(assignments) #SET(assignments,'')
#IF(REGEXREPLACE('[^a-z]',%'{@type}'%,'') IN ['unsigned','integer','real','decimal','udecimal'])
// Denormalize the data using the #EXPAND string constructed above.
%dIDs%:=PROJECT(TABLE(%dInPrep%,{TYPEOF( %id%:=id},id,MERGE),TRANSFORM({lOut;TYPEOF( %id%;},SELF:=LEFT;SELF:=[];));
Jump to Line
Something went wrong with that request. Please try again.