Re: Creating an array thru scripting

Hi,

so let me give you a tiny example with 2 options:

tuple t2
{
string st;
int i;
}

tuple t3
{
key string st;
key int i;
int j;
}

{t2}s2=

 {<"A" ,1 >,
<"B", 2 >,
<"D", 5>,
<"K", 9  >};

{t3} s3;
int value[s2];

execute
{
s3.add(“K”,9, 8);
s3.add(“D”, 5, 7);
s3.add(“A”, 1 ,19);
s3.add(“B”, 2 ,4 );

for(var l in s3) value[s2.find(l.st,l.i)]=l.j;

}

int value2[k in s2]=item(s3,).j;

execute
{
writeln(value);

writeln(value2);
}

 

gives

 

[19 4 7 8]  [19 4 7 8]

regards

 

Many other how to with OPL at https://www.linkedin.com/pulse/how-opl-alex-fleischer/

Source: Re: Creating an array thru scripting