Fri Dec 03, 2021 12:34 am
Login Register Lost Password? Contact Us


Why can't I convert this set to a dataset?

Comments and questions related to the Enterprise Control Language

Tue Sep 26, 2017 3:23 pm Change Time Zone

I use the example given in the ECL Language Reference Manual under #LOOP to make a set of numbers. Then I attempt to convert that set into a dataset (see the next to the last line in the code below). By the way the code below is the example given in the language reference manual under #LOOP EXCEPT for the last 2 lines.

The error I get is "Expected a list".

Code: Select all
// This script creates a set attribute definition of the 1st 10
// natural numbers and defines an attribute named "Set10"
#DECLARE (SetString)
#DECLARE (Ndx)
#SET (SetString, '['); //initialize SetString to [
#SET (Ndx, 1); //initialize Ndx to 1
#LOOP
#IF (%Ndx% > 9) //if we've iterated 9 times
#BREAK // break out of the loop
#ELSE //otherwise
#APPEND (SetString, %'Ndx'% + ',');
//append Ndx and comma to SetString
#SET (Ndx, %Ndx% + 1)
//and increment the value of Ndx
#END
#END
#APPEND (SetString, %'Ndx'% + ']'); //add 10th element and closing ]
EXPORT Set10 := %'SetString'%; //generate the ECL code
ds := DATASET(Set10,{UNSIGNED s});
OUTPUT(COUNT(ds));
tlhumphrey2
 
Posts: 260
Joined: Mon May 07, 2012 6:23 pm

Tue Sep 26, 2017 3:53 pm Change Time Zone

Tim,

This line is the problem:
Code: Select all
EXPORT Set10 := %'SetString'%; //generate the ECL code
With the single quotes, you're generating a string instead of the ECL set expression that you actually want. Change it to this:
Code: Select all
EXPORT Set10 := %SetString%; //generate the ECL code
Removing the single quotes generates the ECL code, not the string.

HTH,

Richard
rtaylor
Community Advisory Board Member
Community Advisory Board Member
 
Posts: 1606
Joined: Wed Oct 26, 2011 7:40 pm

Tue Sep 26, 2017 4:43 pm Change Time Zone

Richard,

Thanks so much. That works perfectly.
tlhumphrey2
 
Posts: 260
Joined: Mon May 07, 2012 6:23 pm


Return to ECL

Who is online

Users browsing this forum: No registered users and 1 guest