From de42d1e8c1fe4250d396881d3aa4ebe842aeab77 Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 26 Oct 2009 16:35:51 +0000 Subject: [PATCH] Patch level : 10.0 Files correlati : ve3.exe Ricompilazione Demo : [ ] Commento : Aggiunta funzione YEAR al valutatore di espressioni Ora la get di un campo virtuale inesitente ritorna NULL invece che l'intero campo G1 git-svn-id: svn://10.65.10.50/trunk@19513 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- include/alex.cpp | 14 +++++++------- include/expr.cpp | 13 ++++++++++--- include/expr.h | 3 ++- include/recset.cpp | 4 +++- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/include/alex.cpp b/include/alex.cpp index 0e8fd61b5..5cb4c4c8b 100755 --- a/include/alex.cpp +++ b/include/alex.cpp @@ -853,10 +853,12 @@ void TAVM::execute(const TAVM_op& op) } break; case avm_dot: - if (_outstr != NULL) - *_outstr << _stack.pop().as_string(); - else - xvtil_popup_message(_stack.pop().as_string()); + { + const TString& msg = _stack.pop().as_string(); + if (_outstr != NULL) + *_outstr << msg; + // else xvtil_popup_message(msg); // More annoying than useful :-) + } break; case avm_drop: if (!_stack.drop()) @@ -866,9 +868,7 @@ void TAVM::execute(const TAVM_op& op) } break; case avm_dup: _stack.push(_stack.peek()); break; - case avm_else: - _ip = op.var().as_int(); - break; + case avm_else: _ip = op.var().as_int(); break; case avm_fetch: do_fetch(_stack.pop().as_string()); break; case avm_forget: { diff --git a/include/expr.cpp b/include/expr.cpp index 33cbe684a..15d0f8fc7 100755 --- a/include/expr.cpp +++ b/include/expr.cpp @@ -820,6 +820,12 @@ void TExpression::eval() evalstack.push(good ? UNO : ZERO); } break; + case _year: + { + const TDate d = evalstack.pop_string(); + evalstack.push(d.year()); + } + break; default: NFCHECK("operazione non valida %d", (int) instr.getsym()); break; @@ -839,14 +845,14 @@ HIDDEN char _tok[81]; TCodesym TExpression::tok2fun(const char* tok) const { - const int MAX_TOK = 31; + const int MAX_TOK = 32; HIDDEN const char* fnstr[MAX_TOK] = { "ANSI", "BETWEEN","CEIL", "CF_CHECK","COS", "EXP", "EXP10", "IF", "LEFT", "LEN", "LOG", "LOG10", "MAX", "MID", "MIN", "NUM", "PERC", "PI_CHECK","POW", "RIGHT", "ROUND", "SCORP", "SIN", "SQR", "SQRT", "STR", "SUBSTR", "TAN", "TRIM", "TRUNC", - "UPPER" }; + "UPPER", "YEAR" }; HIDDEN TCodesym fntok[MAX_TOK] = { _ansi, _between, _ceil, _cfcheck, _cos, _exp, _exp10, _if, _left, _len, @@ -854,7 +860,7 @@ TCodesym TExpression::tok2fun(const char* tok) const _num, _perc, _picheck, _pow, _right, _round, _scorp, _sin, _sqr, _sqrt, _str, _substr, _tan, _trim, _trunc, - _upper }; + _upper, _year }; int f = 0, l = MAX_TOK-1, i = MAX_TOK/2; for (;;) @@ -1168,6 +1174,7 @@ TCodesym TExpression::__factor(TCodesym startsym) case _upper: case _trim: case _len: + case _year: sym = __function(1); _code.add(startsym); break; diff --git a/include/expr.h b/include/expr.h index 948afa5a2..e32c54740 100755 --- a/include/expr.h +++ b/include/expr.h @@ -71,7 +71,8 @@ enum TCodesym { _trim, // @emem Elimina spazi iniziali e finali di una stringa _between, // @emem controlla se il primo argomento e' compreso tra gli altri due _cfcheck, // @emem controlla il codice fiscale (+stato) - _picheck // @emem controlla la partita IVA (+stato) + _picheck, // @emem controlla la partita IVA (+stato) + _year // @emem estrae l'anno da una data }; // @doc INTERNAL diff --git a/include/recset.cpp b/include/recset.cpp index 6dc9a36ff..550261967 100755 --- a/include/recset.cpp +++ b/include/recset.cpp @@ -1425,9 +1425,11 @@ const TVariant& TISAM_recordset::get_field(int logic, const char* fldname) const const int e = str.find('\n', s); var.set(str.sub(s, e)); } + else + var.set_null(); } - if (to >= from) + if (to >= from && !var.is_empty()) var.set(var.as_string().sub(from-1, to)); return var;