Wed Feb 20, 2019 1:29 am
Login Register Lost Password? Contact Us


Request help using #GETDATATYPE in MACRO

Comments and questions related to the Enterprise Control Language

Thu Jan 31, 2019 8:40 pm Change Time Zone

Ah! Reading comprehension fails me sometimes. Probably more often than "sometimes" but we won't get into that.

Does this resemble your code?

Code: Select all
ConcatFieldValues(inFile, outFieldType, outField, inField, delim = '\'\'') := FUNCTIONMACRO
    LOCAL onlyFieldData := PROJECT
        (
            inFile,
            TRANSFORM
                (
                    {
                        outFieldType    outField
                    },
                    SELF.outField := (outFieldType)LEFT.inField
                )
        );
   
    LOCAL rolledUpData := ROLLUP
        (
            onlyFieldData,
            TRUE,
            TRANSFORM
                (
                    RECORDOF(LEFT),
                    SELF.outField := LEFT.outField + (outFieldType)delim + RIGHT.outField
                )
        );
   
    RETURN rolledUpData;
ENDMACRO;

//------------------------------------------------------------------------------

DataRec := RECORD
    QSTRING     fname;
    STRING1     mname_initial;
    STRING      lname;
    UNSIGNED1   age;
END;

ds := DATASET
    (
        [
            {'Dan', 'S', 'Camper', 53},
            {'John', 'Q', 'Public', 21},
            {'Jane', '', 'Doe', 23}
        ],
        DataRec
    );

ConcatFieldValues(ds, STRING, myOut, fname, ',');
ConcatFieldValues(ds, STRING, myOut, lname, ',');
ConcatFieldValues(ds, QSTRING, myOut, mname_initial, ':');
ConcatFieldValues(ds, UTF8, myOut, age, ';');
ConcatFieldValues(ds, STRING, myOut, fname, 0);
DSC
Community Advisory Board Member
Community Advisory Board Member
 
Posts: 554
Joined: Tue Oct 18, 2011 4:45 pm

Previous

Return to ECL

Who is online

Users browsing this forum: No registered users and 1 guest