Added LEFT() expression function.
This commit is contained in:
parent
8299aeaea9
commit
fa711ddf86
16
Operand.cpp
16
Operand.cpp
@ -11,16 +11,12 @@ namespace jet {
|
||||
|
||||
in.skipWhitespace();
|
||||
|
||||
// std::cout << "op: [" << in.unparsed() << "]" << std::endl;
|
||||
|
||||
if(in.ifNext("(")) {
|
||||
// std::cout << "(" << in.unparsed() << std::endl;
|
||||
Operand op(in);
|
||||
string = op.string;
|
||||
doubleValue = op.doubleValue;
|
||||
if(!in.ifNext(")"))
|
||||
throw coreutils::Exception("expected ) in expression.");
|
||||
// std::cout << ")" << in.unparsed() << std::endl;
|
||||
}
|
||||
|
||||
if(in.ifNext("SUBSTRING")) {
|
||||
@ -42,7 +38,17 @@ namespace jet {
|
||||
else
|
||||
throw coreutils::Exception("Expecting ) at end of substring expression.");
|
||||
} else if(in.ifNext("LEFT")) {
|
||||
|
||||
if(!in.ifNext("("))
|
||||
throw coreutils::Exception("Expecting ( for LEFT parameters.");
|
||||
Operand parm1(in);
|
||||
if(!in.ifNext(","))
|
||||
throw coreutils::Exception("Expecting , in LEFT expression.");
|
||||
Operand parm2(in);
|
||||
if(in.ifNext(")")) {
|
||||
string = parm1.string.substring(0, parm2.string.asInteger());
|
||||
}
|
||||
else
|
||||
throw coreutils::Exception("Expecting ) at end of LEFT expression.");
|
||||
} else if(in.ifNext("RIGHT")) {
|
||||
|
||||
} else if(in.ifNext("TRIM")) {
|
||||
|
@ -21,6 +21,9 @@
|
||||
<set name="divisor" value="8" />
|
||||
<set name="nested" expr="(2*(4+4)/$[divisor])*32" />
|
||||
$[nested]
|
||||
<set name="numbers">0123456789</set>
|
||||
<set name="lefty" expr="LEFT('$[numbers]',5)" />
|
||||
lefty=[$[lefty]]
|
||||
substring('abcdefg', 1, 3)=[$[theexpr]]
|
||||
5+3=($[addition])
|
||||
5-3($[subtraction])
|
||||
|
Loading…
x
Reference in New Issue
Block a user