Choose Language Hide Translation Bar

## Dynamic Graph Builder - Eval Expr places extra parenthesis into Elements - help please

Hi there,

I have the following code which places x amount of variables into graph builder using the Eval Expr.  When I get to the Elements phase, I find that extra parenthesises are placed at the end giving the folooing expression (shorterned):

`Elements(Position(1, 1), Line(X, Y, Legend(37)),     Elements(Position(1, 3), Line(X, Y, Legend(39))),    Elements(Position(1, 19), Line(X, Y, Legend(55))),     Elements(Position(1, 20), Line(X, Y, Legend(56))))`

To me it there is a missing parenthesis in line one and an extra parenthesis on line 4 closing the statement off.

`    Elements(Position(1, 4), Line(X, Y, Legend(40))),     Elements(Position(1, 5), Line(X, Y, Legend(41))),     Elements(Position(1, 6), Line(X, Y, Legend(42))),`

My assumption is the Eval Expr is not the correct syntax for this part.

`graphArray_Items = N Items( graphArray );alertArray_Items = N Items (alertArray);// an expression for the graph's variables vars = Expr( Variables( X( :EFH ),  ) );_elements = Expr (Elements( Position( 1, 1 ), Line( X, Y, Legend( 37 ) ) ) ,);show(_dispatch);For (intArray = 1, intArray <= graphArray_Items, intArray ++,            //Find Column Number            graphArray_source = graphArray[intArray];                        Insert Into( vars, Eval Expr( Y( Expr( "SB"|| graphArray_source ||"_DRVD_XNULL" )), Position( 1 )  ) );                          Insert Into( _elements, Eval Expr( Elements( Position( 1, Expr(intArray+2) ) , Line ( X,Y,  Legend ( Expr(intArray+38) ) ) ),  ));                                                show(_elements);                // build the Graph Builder expression from those  gb = Eval Expr(    Graph Builder(   Size( 1431, 928 ),   Show Control Panel( 0 ),    Expr( Name Expr( vars ) ),   Expr(Name Expr (_elements))//,  //Expr(Name Expr (_dispatch))  )  );  show(gb);gb;graphArray_Items = N Items( graphArray );alertArray_Items = N Items (alertArray);// an expression for the graph's variables vars = Expr( Variables( X( :EFH ),  ) );_elements = Expr (Elements( Position( 1, 1 ), Line( X, Y, Legend( 37 ) ) ) ,);//_dispatch = Expr (SendToReport());show(_dispatch);`
1 ACCEPTED SOLUTION

Accepted Solutions

Staff

Joined:

Mar 21, 2013

Solution

## Re: Dynamic Graph Builder - Eval Expr places extra parenthesis into Elements - help please

Build the expression up one argument at a time, inside the function (graph builder) that uses the arguments.  The parens in your original code represent making the first elements have child elements rather than making sibling elements in the graph builder function.

`gb = Expr( graphbuilder() );Insert Into( gb, Expr( Size( 1431, 928 ) ) );Insert Into( gb, Expr( Show Control Panel( 0 ) ) );Insert Into( gb, Expr( elements( 1 ) ) );Insert Into( gb, Expr( elements( 2 ) ) );Insert Into( gb, Expr( elements( 3 ) ) );Show( Name Expr( gb ) );`

Name Expr(gb) = graphbuilder(Size(1431, 928), Show Control Panel(0), elements(1), elements(2), elements(3));

`gb = Expr(  graphbuilder( Size( 1431, 928 ), Show Control Panel( 0 ) ));Insert Into( gb, Expr( elements( 1 ) ) );Insert Into( gb, Expr( elements( 2 ) ) );Insert Into( gb, Expr( elements( 3 ) ) );Show( Name Expr( gb ) );`

will give the same results.  InsertInto can also specify the index if you want to squeeze a parameter in somewhere other than the end of the list.  See Introspection for some other ideas.

Craige
2 REPLIES 2

Staff

Joined:

Mar 21, 2013

Solution

## Re: Dynamic Graph Builder - Eval Expr places extra parenthesis into Elements - help please

Build the expression up one argument at a time, inside the function (graph builder) that uses the arguments.  The parens in your original code represent making the first elements have child elements rather than making sibling elements in the graph builder function.

`gb = Expr( graphbuilder() );Insert Into( gb, Expr( Size( 1431, 928 ) ) );Insert Into( gb, Expr( Show Control Panel( 0 ) ) );Insert Into( gb, Expr( elements( 1 ) ) );Insert Into( gb, Expr( elements( 2 ) ) );Insert Into( gb, Expr( elements( 3 ) ) );Show( Name Expr( gb ) );`

Name Expr(gb) = graphbuilder(Size(1431, 928), Show Control Panel(0), elements(1), elements(2), elements(3));

`gb = Expr(  graphbuilder( Size( 1431, 928 ), Show Control Panel( 0 ) ));Insert Into( gb, Expr( elements( 1 ) ) );Insert Into( gb, Expr( elements( 2 ) ) );Insert Into( gb, Expr( elements( 3 ) ) );Show( Name Expr( gb ) );`

will give the same results.  InsertInto can also specify the index if you want to squeeze a parameter in somewhere other than the end of the list.  See Introspection for some other ideas.

Craige

## Re: Dynamic Graph Builder - Eval Expr places extra parenthesis into Elements - help please

Thank you for you help. Works wonderfully