Opened 20 years ago

Closed 20 years ago

#515 closed defect (duplicate)

setExpression with a variable

Reported by: tmelhuish@… Owned by: sdlime
Priority: high Milestone:
Component: MapScript Version: 4.1
Severity: normal Keywords:
Cc:

Description

I'm trying to set a class expression in mapscript using a variable. I can copy 
the value if my variable into the setExpression() method and it works fine but 
I get nothing when substituting the variable. I tried all sorts of delimiter 
combinations with no sucess. Also, is thier a better way to define this 
statement nore like an SQL statement? (ie "[nodeid] in(595.0,436.1,...) My 
mapscript code is as follows:

+++++++++++++++++++++++++++++++
$expstr="'([nodeid] eq 436.4 OR [nodeid] eq 436.2 OR [nodeid] eq 436.1 OR 
[nodeid] eq 434.0 OR [nodeid] eq 595.0 OR [nodeid] eq 553.0 OR [nodeid] eq 
435.4 OR [nodeid] eq 452.0 OR [nodeid] eq 426.0 OR [nodeid] eq 435.2)'";
			
print "**ExpStr:$_,$minctr, $maxctr, $expstr <br>\n";

$class=$layer->getClass(0);

## This DOES NOT work!!			
$rv = $class->setExpression( $expstr );

## Either of these statements work fine and produce the results expected
#
#$rv = $class->setExpression('([nodeid] eq 436.1 OR [nodeid] eq 436.2)');
#$rv = $class->setExpression('([nodeid] eq 436.4 OR [nodeid] eq 436.2 OR 
[nodeid] eq 436.1 OR [nodeid] eq 434.0 OR [nodeid] eq 595.0 OR [nodeid] eq 
553.0 OR [nodeid] eq 435.4 OR [nodeid] eq 452.0 OR [nodeid] eq 426.0 OR 
[nodeid] eq 435.2)');
			
$rv == $mapscript::MS_SUCCESS or &Error('can not setExpression in class index 
$classindx layer nodes_oldnew',"error");

+++++++++++++++++++++++++++++++++++++++++++++++++++

Change History (1)

comment:1 by sdlime, 20 years ago

Resolution: duplicate
Status: newclosed

*** This bug has been marked as a duplicate of 514 ***
Note: See TracTickets for help on using tickets.