Patch level :
Files correlati : Ricompilazione Demo : [ ] Commento : Allineamenti a varie modifiche della 1.5 git-svn-id: svn://10.65.10.50/trunk@7610 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
d4ca44125c
commit
e2a275e3ba
@ -71,7 +71,7 @@ TObject* TDowJones::rec2obj(const TRectype& rec) const
|
|||||||
|
|
||||||
if (data->_den <= ZERO)
|
if (data->_den <= ZERO)
|
||||||
{
|
{
|
||||||
NFCHECK("Codice valuta assente");
|
NFCHECK("Codice valuta non valido '%s'", (const char*)rec.get("CODTAB"));
|
||||||
data->_den = 1.0;
|
data->_den = 1.0;
|
||||||
data->_num = 1.0;
|
data->_num = 1.0;
|
||||||
}
|
}
|
||||||
|
206
include/expr.cpp
206
include/expr.cpp
@ -1,18 +1,13 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define __EXPR_CPP
|
#define __EXPR_CPP
|
||||||
#include <expr.h>
|
#include <expr.h>
|
||||||
#include <stack.h>
|
#include <stack.h>
|
||||||
|
#include <utility.h>
|
||||||
#include <date.h>
|
#include <date.h>
|
||||||
|
|
||||||
TValue::TValue(const real& val)
|
|
||||||
{
|
|
||||||
_r = val;
|
|
||||||
_s = val.string();
|
|
||||||
_t = _numexpr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TCodearray::clear()
|
void TCodearray::clear()
|
||||||
{
|
{
|
||||||
destroy();
|
destroy();
|
||||||
@ -51,55 +46,54 @@ void TVararray::add(const char* name, const TValue& val)
|
|||||||
|
|
||||||
void TVararray::set(const char* name, const real& val)
|
void TVararray::set(const char* name, const real& val)
|
||||||
{
|
{
|
||||||
for (int i = items()-1; i >= 0; i--)
|
for (int i = last(); i >= 0; i--)
|
||||||
{
|
{
|
||||||
TVar* var = (TVar*)objptr(i);
|
TVar* var = (TVar*)objptr(i);
|
||||||
CHECKS(var, "Variabile NULLA ", name);
|
|
||||||
if (strcmp(var->getname(), name) == 0)
|
if (strcmp(var->getname(), name) == 0)
|
||||||
{
|
{
|
||||||
*var = val;
|
*var = val;
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
NFCHECK("Variabile non trovata: %s", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TVararray::set(const char* name, const char* val)
|
void TVararray::set(const char* name, const char* val)
|
||||||
{
|
{
|
||||||
for (int i = items()-1; i >= 0; i--)
|
for (int i = last(); i >= 0; i--)
|
||||||
{
|
{
|
||||||
TVar* var = (TVar*)objptr(i);
|
TVar* var = (TVar*)objptr(i);
|
||||||
CHECKS(var, "Variabile NULLA ", name);
|
|
||||||
if (strcmp(var->getname(), name) == 0)
|
if (strcmp(var->getname(), name) == 0)
|
||||||
{
|
{
|
||||||
*var = val;
|
*var = val;
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
NFCHECK("Variabile non trovata: %s", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const real& TVararray::getnum(const char* name)
|
const real& TVararray::getnum(const char* name)
|
||||||
{
|
{
|
||||||
for (int i = items()-1; i >= 0; i--)
|
for (int i = items()-1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
const TVar* var = (const TVar*)objptr(i);
|
TVar* var = (TVar*)objptr(i);
|
||||||
if (strcmp(var->getname(), name) == 0)
|
if (var && strcmp(var->getname(), name) == 0)
|
||||||
return var->number();
|
return var->number();
|
||||||
}
|
}
|
||||||
NFCHECK("Unknown variable: %s", name);
|
NFCHECK("Unknown variable: %s", name);
|
||||||
return ZERO;
|
return ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const real& TVararray::getnum(int varnum)
|
const real& TVararray::getnum(int varnum)
|
||||||
{
|
{
|
||||||
const TVar* var = (const TVar*)objptr(varnum);
|
if (varnum < 0 || varnum >= items())
|
||||||
if (var == NULL)
|
|
||||||
{
|
{
|
||||||
NFCHECK("Invalid variable number : %d", varnum);
|
NFCHECK("Invalid variable number : %d", varnum);
|
||||||
return ZERO;
|
return "";
|
||||||
}
|
}
|
||||||
return var->number();
|
return ((TVar*)objptr(varnum))->number();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -107,22 +101,23 @@ const TString& TVararray::getstring(const char* name)
|
|||||||
{
|
{
|
||||||
for (int i = items()-1; i >= 0; i--)
|
for (int i = items()-1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
const TVar* var = (TVar*)objptr(i);
|
TVar* var = (TVar*)objptr(i);
|
||||||
if (strcmp(var->getname(), name) == 0)
|
if (var && strcmp(var->getname(), name) == 0)
|
||||||
return var->string();
|
return var->string();
|
||||||
}
|
}
|
||||||
NFCHECK("Unknown variable : %s", name);
|
NFCHECK("Unknown variable : %s", name);
|
||||||
return EMPTY_STRING;
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const TString& TVararray::getstring(int varnum)
|
const TString& TVararray::getstring(int varnum)
|
||||||
{
|
{
|
||||||
const TVar* var = (const TVar*)objptr(varnum);
|
if (varnum < 0 || varnum >= items())
|
||||||
if (var == NULL)
|
|
||||||
{
|
{
|
||||||
NFCHECK("Invalid variable number : %d", varnum);
|
NFCHECK("Invalid variable number : %d", varnum);
|
||||||
return EMPTY_STRING;
|
return "";
|
||||||
}
|
}
|
||||||
|
TVar* var = (TVar*)objptr(varnum);
|
||||||
return var->string();
|
return var->string();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,100 +125,86 @@ const TString& TVararray::getstring(int varnum)
|
|||||||
// TEval_stack
|
// TEval_stack
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void TEval_stack::push(bool b)
|
||||||
|
{
|
||||||
|
if (_sp < _data.items())
|
||||||
|
{
|
||||||
|
_sp++;
|
||||||
|
peek_real() = b ? 1.0 : 0.0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
TStack::push(new TValue(b ? real(1.0) : ZERO));
|
||||||
|
}
|
||||||
|
|
||||||
|
void TEval_stack::push(int n)
|
||||||
|
{
|
||||||
|
if (_sp < _data.items())
|
||||||
|
{
|
||||||
|
_sp++;
|
||||||
|
peek_real() = n;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
TStack::push(new TValue(real(n)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void TEval_stack::push(const real& r)
|
void TEval_stack::push(const real& r)
|
||||||
{
|
{
|
||||||
if (_data.items() > _sp)
|
if (_sp < _data.items())
|
||||||
{
|
{
|
||||||
_sp++;
|
_sp++;
|
||||||
peek_real() = r;
|
peek_real() = r;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
TStack::push(r);
|
TStack::push(new TValue(r));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEval_stack::push(const TString& s)
|
void TEval_stack::push(const TString& s)
|
||||||
{
|
{
|
||||||
if (_data.items() > _sp)
|
if (_sp < _data.items())
|
||||||
{
|
{
|
||||||
_sp++;
|
_sp++;
|
||||||
peek_string() = s;
|
peek_string() = s;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
TStack::push(s);
|
TStack::push(new TValue(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TEval_stack::push(const char* s)
|
void TEval_stack::push(const char* s)
|
||||||
{
|
{
|
||||||
if (_data.items() > _sp)
|
if (_sp < _data.items())
|
||||||
{
|
{
|
||||||
_sp++;
|
_sp++;
|
||||||
peek_string() = s;
|
peek_string() = s;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
TStack::push(new TString80(s));
|
TStack::push(new TValue(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
real& TEval_stack::pop_real()
|
real& TEval_stack::pop_real()
|
||||||
{
|
{
|
||||||
TObject& o = pop();
|
TValue& o = (TValue&)pop();
|
||||||
if (o.class_id() == CLASS_STRING)
|
return o.number();
|
||||||
{
|
|
||||||
real* r = new real((TString&)o);
|
|
||||||
TStack::push(r);
|
|
||||||
return (real&)pop();
|
|
||||||
}
|
|
||||||
return (real&)o;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
real& TEval_stack::peek_real()
|
real& TEval_stack::peek_real()
|
||||||
{
|
{
|
||||||
TObject& o = peek(0);
|
TValue& o = (TValue&)peek(0);
|
||||||
if (o.class_id() == CLASS_STRING)
|
return o.number();
|
||||||
{
|
|
||||||
pop();
|
|
||||||
real* r = new real((TString&)o);
|
|
||||||
TStack::push(r);
|
|
||||||
return *r;
|
|
||||||
}
|
|
||||||
return (real&)o;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TString& TEval_stack::pop_string()
|
TString& TEval_stack::pop_string()
|
||||||
{
|
{
|
||||||
TObject& o = pop();
|
TValue& o = (TValue&)pop();
|
||||||
if (o.class_id() == CLASS_STRING)
|
return o.string();
|
||||||
return (TString&)o;
|
|
||||||
|
|
||||||
TString* s = new TString80(((real&)o).string());
|
|
||||||
TStack::push(s);
|
|
||||||
return (TString&)pop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TString& TEval_stack::peek_string()
|
TString& TEval_stack::peek_string()
|
||||||
{
|
{
|
||||||
TObject& o = peek();
|
TValue& o = (TValue&)peek(0);
|
||||||
if (o.class_id() == CLASS_STRING)
|
return o.string();
|
||||||
return (TString&)o;
|
|
||||||
|
|
||||||
pop();
|
|
||||||
TString* s = new TString80(((real&)o).string());
|
|
||||||
TStack::push(s);
|
|
||||||
return *s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TEval_stack::pop_bool()
|
|
||||||
{
|
|
||||||
TObject& o = pop();
|
|
||||||
if (o.class_id() == CLASS_STRING)
|
|
||||||
{
|
|
||||||
const real r = (TString&)o;
|
|
||||||
return !r.is_zero();
|
|
||||||
}
|
|
||||||
return !((real&)o).is_zero();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
// TExpression
|
// TExpression
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
@ -234,7 +215,6 @@ TExpression::TExpression(const char* expression, TTypeexp type, bool ignore_err)
|
|||||||
{
|
{
|
||||||
_ignore_error=ignore_err;
|
_ignore_error=ignore_err;
|
||||||
_error=0;
|
_error=0;
|
||||||
_val = ZERO;
|
|
||||||
_dirty = TRUE;
|
_dirty = TRUE;
|
||||||
_type = type;
|
_type = type;
|
||||||
compile(_original, type);
|
compile(_original, type);
|
||||||
@ -246,7 +226,6 @@ TExpression::TExpression(TTypeexp type, bool ignore_err)
|
|||||||
{
|
{
|
||||||
_ignore_error=ignore_err;
|
_ignore_error=ignore_err;
|
||||||
_error=0;
|
_error=0;
|
||||||
_val = ZERO;
|
|
||||||
_dirty = FALSE;
|
_dirty = FALSE;
|
||||||
_type = type;
|
_type = type;
|
||||||
_code.clear();
|
_code.clear();
|
||||||
@ -269,8 +248,7 @@ TObject* TExpression::dup() const
|
|||||||
|
|
||||||
const real & TExpression::as_real()
|
const real & TExpression::as_real()
|
||||||
{
|
{
|
||||||
if (user_func_dirty() || _dirty)
|
if (user_func_dirty() || _dirty) eval();
|
||||||
eval();
|
|
||||||
_dirty = FALSE;
|
_dirty = FALSE;
|
||||||
return _val.number();
|
return _val.number();
|
||||||
}
|
}
|
||||||
@ -296,13 +274,11 @@ void TExpression::evaluate_user_func(int index, int nparms, TEval_stack& stack,
|
|||||||
NFCHECK("Unknown function %d.", index);
|
NFCHECK("Unknown function %d.", index);
|
||||||
for ( int i = nparms ; i > 0; i--)
|
for ( int i = nparms ; i > 0; i--)
|
||||||
stack.pop();
|
stack.pop();
|
||||||
if (curtype == _numexpr)
|
|
||||||
stack.push(ZERO);
|
stack.push(ZERO);
|
||||||
else
|
|
||||||
stack.push("");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TExpression::setvar(const char* varname, const real& val)
|
void TExpression::setvar(const char* varname, const real& val)
|
||||||
|
|
||||||
{
|
{
|
||||||
if (_var.getnum(varname) != val)
|
if (_var.getnum(varname) != val)
|
||||||
{
|
{
|
||||||
@ -313,6 +289,7 @@ void TExpression::setvar(const char* varname, const real& val)
|
|||||||
|
|
||||||
|
|
||||||
void TExpression::setvar(int varnum, const real& val)
|
void TExpression::setvar(int varnum, const real& val)
|
||||||
|
|
||||||
{
|
{
|
||||||
if (_var.getnum(varnum) != val)
|
if (_var.getnum(varnum) != val)
|
||||||
{
|
{
|
||||||
@ -422,13 +399,11 @@ void TExpression::eval()
|
|||||||
if (r.is_zero())
|
if (r.is_zero())
|
||||||
{
|
{
|
||||||
if (!evalstack.peek_real().is_zero())
|
if (!evalstack.peek_real().is_zero())
|
||||||
{
|
if (_ignore_error)
|
||||||
_error=1;
|
_error=1;
|
||||||
if (!_ignore_error)
|
|
||||||
print_error("Divisione per zero!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
|
print_error("Divisione per zero!");
|
||||||
|
} else
|
||||||
evalstack.peek_real() /= r;
|
evalstack.peek_real() /= r;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -440,16 +415,16 @@ void TExpression::eval()
|
|||||||
break;
|
break;
|
||||||
case _and:
|
case _and:
|
||||||
{
|
{
|
||||||
const bool r2 = evalstack.pop_bool();
|
const real & r2 = evalstack.pop_real();
|
||||||
const bool r1 = evalstack.pop_bool();
|
real & r1 = evalstack.peek_real();
|
||||||
evalstack.push(real(r1 && r2 ? 1.0 : 0.0));
|
r1 = (!r1.is_zero() && !r2.is_zero()) ? 1.0 : 0.0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case _or:
|
case _or:
|
||||||
{
|
{
|
||||||
const bool r2 = evalstack.pop_bool();
|
const real & r2 = evalstack.pop_real();
|
||||||
const bool r1 = evalstack.pop_bool();
|
real & r1 = evalstack.peek_real();
|
||||||
evalstack.push(real(r1 || r2 ? 1.0 : 0.0));
|
r1 = (r1 != ZERO || r2 != ZERO) ? 1.0 : 0.0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case _not:
|
case _not:
|
||||||
@ -463,7 +438,7 @@ void TExpression::eval()
|
|||||||
{
|
{
|
||||||
const TString & s2 = evalstack.pop_string();
|
const TString & s2 = evalstack.pop_string();
|
||||||
const TString & s1 = evalstack.pop_string();
|
const TString & s1 = evalstack.pop_string();
|
||||||
evalstack.push(real(s1 == s2 ? 1.0 : 0.0));
|
evalstack.push(s1 == s2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -476,7 +451,7 @@ void TExpression::eval()
|
|||||||
{
|
{
|
||||||
const TString & s2 = evalstack.pop_string();
|
const TString & s2 = evalstack.pop_string();
|
||||||
const TString & s1 = evalstack.pop_string();
|
const TString & s1 = evalstack.pop_string();
|
||||||
evalstack.push(real(s1.match(s2) ? 1.0 : 0.0));
|
evalstack.push(s1.match(s2));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case _noteq:
|
case _noteq:
|
||||||
@ -484,7 +459,7 @@ void TExpression::eval()
|
|||||||
{
|
{
|
||||||
const TString & s2 = evalstack.pop_string();
|
const TString & s2 = evalstack.pop_string();
|
||||||
TString & s1 = evalstack.pop_string();
|
TString & s1 = evalstack.pop_string();
|
||||||
evalstack.push(real(s1 != s2 ? 1.0 : 0.0));
|
evalstack.push(s1 != s2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -498,7 +473,7 @@ void TExpression::eval()
|
|||||||
{
|
{
|
||||||
const TString & s2 = evalstack.pop_string();
|
const TString & s2 = evalstack.pop_string();
|
||||||
const TString & s1 = evalstack.pop_string();
|
const TString & s1 = evalstack.pop_string();
|
||||||
evalstack.push(real(s1 < s2 ? 1.0 : 0.0));
|
evalstack.push(s1 < s2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -512,7 +487,7 @@ void TExpression::eval()
|
|||||||
{
|
{
|
||||||
const TString & s2 = evalstack.pop_string();
|
const TString & s2 = evalstack.pop_string();
|
||||||
const TString & s1 = evalstack.pop_string();
|
const TString & s1 = evalstack.pop_string();
|
||||||
evalstack.push(real(s1 > s2 ? 1.0 : 0.0));
|
evalstack.push(s1 > s2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -526,7 +501,7 @@ void TExpression::eval()
|
|||||||
{
|
{
|
||||||
const TString& s2 = evalstack.pop_string();
|
const TString& s2 = evalstack.pop_string();
|
||||||
const TString& s1 = evalstack.pop_string();
|
const TString& s1 = evalstack.pop_string();
|
||||||
evalstack.push(real(s1 <= s2 ? 1.0 : 0.0));
|
evalstack.push(s1 <= s2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -540,7 +515,7 @@ void TExpression::eval()
|
|||||||
{
|
{
|
||||||
const TString& s2 = evalstack.pop_string();
|
const TString& s2 = evalstack.pop_string();
|
||||||
const TString& s1 = evalstack.pop_string();
|
const TString& s1 = evalstack.pop_string();
|
||||||
evalstack.push(real(s1 >= s2 ? 1.0 : 0.0));
|
evalstack.push(s1 >= s2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -562,8 +537,9 @@ void TExpression::eval()
|
|||||||
real& r = evalstack.peek_real();
|
real& r = evalstack.peek_real();
|
||||||
if (r < ZERO)
|
if (r < ZERO)
|
||||||
{
|
{
|
||||||
|
if (_ignore_error)
|
||||||
_error=1;
|
_error=1;
|
||||||
if (!_ignore_error)
|
else
|
||||||
print_error("Radice negativa!");
|
print_error("Radice negativa!");
|
||||||
r = -r;
|
r = -r;
|
||||||
}
|
}
|
||||||
@ -630,7 +606,7 @@ void TExpression::eval()
|
|||||||
case _len:
|
case _len:
|
||||||
{
|
{
|
||||||
TString& s1 = evalstack.pop_string();
|
TString& s1 = evalstack.pop_string();
|
||||||
evalstack.push(real(s1.len()));
|
evalstack.push(s1.len());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case _pow:
|
case _pow:
|
||||||
@ -700,8 +676,8 @@ void TExpression::eval()
|
|||||||
{
|
{
|
||||||
const TString & s1 = evalstack.pop_string();
|
const TString & s1 = evalstack.pop_string();
|
||||||
const TString & s2 = evalstack.pop_string();
|
const TString & s2 = evalstack.pop_string();
|
||||||
const bool cond = evalstack.pop_bool();
|
const real & cond = evalstack.pop_real();
|
||||||
evalstack.push(cond ? s2 : s1);
|
evalstack.push(cond.is_zero() ? s1 : s2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -747,14 +723,9 @@ void TExpression::eval()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// L'espressione non e' vuota
|
// Lo stack non e' vuoto
|
||||||
if (_code.items() > 1)
|
if (_code.items() > 1)
|
||||||
{
|
_val = (const TValue&)evalstack.pop();
|
||||||
if (_type == _strexpr)
|
|
||||||
_val = evalstack.pop_string();
|
|
||||||
else
|
|
||||||
_val = evalstack.pop_real();
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
_val = ZERO;
|
_val = ZERO;
|
||||||
}
|
}
|
||||||
@ -1061,8 +1032,7 @@ TCodesym TExpression::__factor(TCodesym startsym)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
_code.add(_number, real(__parms_found));
|
_code.add(_number, real(__parms_found));
|
||||||
TString16 str; str.format("%d", index);
|
val.set(format("%d", index));
|
||||||
val.set(str);
|
|
||||||
_code.add(startsym, val);
|
_code.add(startsym, val);
|
||||||
_user_func_defined = TRUE;
|
_user_func_defined = TRUE;
|
||||||
}
|
}
|
||||||
@ -1191,11 +1161,11 @@ bool TExpression::set(const char* expression, TTypeexp type)
|
|||||||
|
|
||||||
bool TExpression::compile(const TString& expression, TTypeexp type)
|
bool TExpression::compile(const TString& expression, TTypeexp type)
|
||||||
{
|
{
|
||||||
_error=0;
|
|
||||||
_user_func_defined = FALSE;
|
_user_func_defined = FALSE;
|
||||||
_s = expression;
|
_s = expression;
|
||||||
_type = type;
|
_type = type;
|
||||||
_val = ZERO;
|
_val = real(0.0);
|
||||||
_code.clear();
|
_code.clear();
|
||||||
if (expression.blank())
|
if (expression.blank())
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -1210,7 +1180,7 @@ bool TExpression::compile(const TString& expression, TTypeexp type)
|
|||||||
if (!_ignore_error)
|
if (!_ignore_error)
|
||||||
{
|
{
|
||||||
TString msg;
|
TString msg;
|
||||||
msg << "Wrong expression : " << _original;
|
msg << "Espressione errata : " << _original;
|
||||||
print_error(msg);
|
print_error(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,15 +83,14 @@ enum TCodesym {
|
|||||||
//
|
//
|
||||||
// @base public | TObject
|
// @base public | TObject
|
||||||
class TValue : public TObject
|
class TValue : public TObject
|
||||||
|
// @author:(INTERNAL) Alex
|
||||||
// @author:(INTERNAL) Sandro
|
|
||||||
{
|
{
|
||||||
// @access:(INTERNAL) Private Member
|
// @access:(INTERNAL) Private Member
|
||||||
|
|
||||||
// @cmember:(INTERNAL) Valore real
|
// @cmember:(INTERNAL) Valore real
|
||||||
real _r;
|
real _r;
|
||||||
// @cmember:(INTERNAL) Valore in formato stringa
|
// @cmember:(INTERNAL) Valore in formato stringa
|
||||||
TString80 _s;
|
TString256 _s;
|
||||||
// @cmember:(INTERNAL) Tipo preferito
|
// @cmember:(INTERNAL) Tipo preferito
|
||||||
TTypeexp _t;
|
TTypeexp _t;
|
||||||
|
|
||||||
@ -102,35 +101,40 @@ public:
|
|||||||
{ _s = val._s; _r = val._r; _t = val._t; return *this; }
|
{ _s = val._s; _r = val._r; _t = val._t; return *this; }
|
||||||
// @cmember Assegnamento di una stringa
|
// @cmember Assegnamento di una stringa
|
||||||
TValue& operator =(const TString& s)
|
TValue& operator =(const TString& s)
|
||||||
{ _s = s; _r = real(s); _t = _strexpr; return *this; }
|
{ _s = s; _t = _strexpr; return *this; }
|
||||||
// @cmember Assegnamento di un numero
|
// @cmember Assegnamento di un numero
|
||||||
TValue& operator =(const real& r)
|
TValue& operator =(const real& r)
|
||||||
{ _s = r.string(); _r = r; _t = _numexpr; return *this; }
|
{ _r = r; _t = _numexpr; return *this; }
|
||||||
// @cmember Ritorna il valore numerico
|
// @cmember Ritorna il valore numerico
|
||||||
const real& number() const
|
real& number()
|
||||||
{ return _r; }
|
{ if (_t == _strexpr) { _r = real(_s); _t = _numexpr; } return _r; }
|
||||||
// @cmember Ritorna il valore come stringa
|
// @cmember Ritorna il valore come stringa
|
||||||
const TString& string() const
|
TString& string()
|
||||||
{ return _s;}
|
{ if (_t == _numexpr) { _s = _r.string(); _t = _strexpr; } return _s; }
|
||||||
// @cmember Setta il valore passato come real
|
// @cmember Setta il valore passato come real
|
||||||
void set(const real& val)
|
void set(const real& val)
|
||||||
{ _r = val; _s = val.string(); _t = _numexpr; }
|
{ _r = val; _t = _numexpr; }
|
||||||
// @cmember Setta il valore passato come stringa
|
// @cmember Setta il valore passato come stringa
|
||||||
void set(const char* val)
|
void set(const char* val)
|
||||||
{ _s = val; _r = real(val); _t = _strexpr; }
|
{ _s = val; _t = _strexpr; }
|
||||||
// @cmember Setta il valore passato come stringa
|
// @cmember Setta il valore passato come stringa
|
||||||
TTypeexp type() const { return _t; }
|
TTypeexp type() const { return _t; }
|
||||||
|
|
||||||
// @cmember Costruttore. Inizializza TValue con un reale
|
// @cmember Costruttore. Inizializza TValue con un reale
|
||||||
TValue(const real& val);
|
TValue(const real& val)
|
||||||
|
{ _r = val; _t = _numexpr; }
|
||||||
// @cmember Costruttore. Inizializza TValue con una stringa
|
// @cmember Costruttore. Inizializza TValue con una stringa
|
||||||
TValue(const char* val)
|
TValue(const char* val)
|
||||||
{ _s = val; _r = real(val); _t = _strexpr; }
|
{ _s = val; _t = _strexpr; }
|
||||||
|
// @cmember Costruttore. Inizializza TValue con una stringa
|
||||||
|
TValue(const TString& val)
|
||||||
|
{ _s = val; _t = _strexpr; }
|
||||||
// @cmember Costruttore. Inizializza TValue con un altro TValue
|
// @cmember Costruttore. Inizializza TValue con un altro TValue
|
||||||
TValue(const TValue& val)
|
TValue(const TValue& val)
|
||||||
{ *this = val; }
|
{ *this = val; }
|
||||||
// @cmember Costruttore. Inizializza TValue a 0,0 e ""
|
// @cmember Costruttore. Inizializza TValue a 0,0 e ""
|
||||||
TValue()
|
TValue()
|
||||||
{ _r = 0.00; _s = ""; }
|
{ }
|
||||||
// @cmember Distruttore
|
// @cmember Distruttore
|
||||||
virtual ~TValue()
|
virtual ~TValue()
|
||||||
{}
|
{}
|
||||||
@ -176,10 +180,10 @@ public:
|
|||||||
TCodesym getsym() const
|
TCodesym getsym() const
|
||||||
{ return _sym;}
|
{ return _sym;}
|
||||||
// @cmember Ritorna il valore come <c real>
|
// @cmember Ritorna il valore come <c real>
|
||||||
const real& number() const
|
real& number()
|
||||||
{ return _val.number(); }
|
{ return _val.number(); }
|
||||||
// @cmember Ritorna il valore come stringa
|
// @cmember Ritorna il valore come stringa
|
||||||
const TString& string() const
|
TString& string()
|
||||||
{ return _val.string(); }
|
{ return _val.string(); }
|
||||||
|
|
||||||
// @cmember Costruttore, inizializza simbolo con "invalid", valore a nullvalue
|
// @cmember Costruttore, inizializza simbolo con "invalid", valore a nullvalue
|
||||||
@ -206,7 +210,7 @@ public:
|
|||||||
// @base public | TArray
|
// @base public | TArray
|
||||||
class TCodearray : public TArray
|
class TCodearray : public TArray
|
||||||
|
|
||||||
// @author:(INTERNAL) Alex
|
// @author:(INTERNAL) Sandro
|
||||||
|
|
||||||
// @access:(INTERNAL) Private Member
|
// @access:(INTERNAL) Private Member
|
||||||
{
|
{
|
||||||
@ -254,7 +258,7 @@ class TVar : public TObject
|
|||||||
{
|
{
|
||||||
|
|
||||||
// @cmember:(INTERNAL) Nome della variabile
|
// @cmember:(INTERNAL) Nome della variabile
|
||||||
TString80 _name;
|
TString _name;
|
||||||
// @cmember:(INTERNAL) Valore assegnato alla variabile
|
// @cmember:(INTERNAL) Valore assegnato alla variabile
|
||||||
TValue _val;
|
TValue _val;
|
||||||
|
|
||||||
@ -289,10 +293,10 @@ public:
|
|||||||
operator TValue&()
|
operator TValue&()
|
||||||
{ return _val;}
|
{ return _val;}
|
||||||
// @cmember Ritorna il valore real della variabile
|
// @cmember Ritorna il valore real della variabile
|
||||||
const real& number() const
|
real& number()
|
||||||
{ return _val.number(); }
|
{ return _val.number(); }
|
||||||
// @cmember Ritorna il valore stringa della variabile
|
// @cmember Ritorna il valore stringa della variabile
|
||||||
const TString& string() const
|
TString& string()
|
||||||
{ return _val.string();}
|
{ return _val.string();}
|
||||||
|
|
||||||
// @cmember Costruttore (assegna "" al campo <p _name> ed il valore nulltvalue al campo <p val>)
|
// @cmember Costruttore (assegna "" al campo <p _name> ed il valore nulltvalue al campo <p val>)
|
||||||
@ -371,15 +375,16 @@ public:
|
|||||||
class TEval_stack : public TStack
|
class TEval_stack : public TStack
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void push(const real& r);
|
|
||||||
void push(const TString& s);
|
|
||||||
void push(const char* s);
|
|
||||||
|
|
||||||
real& pop_real();
|
real& pop_real();
|
||||||
real& peek_real();
|
real& peek_real();
|
||||||
TString& pop_string();
|
TString& pop_string();
|
||||||
TString& peek_string();
|
TString& peek_string();
|
||||||
bool pop_bool();
|
|
||||||
|
void push(bool b);
|
||||||
|
void push(int n);
|
||||||
|
void push(const real& r);
|
||||||
|
void push(const TString& s);
|
||||||
|
void push(const char* s);
|
||||||
};
|
};
|
||||||
|
|
||||||
// @doc EXTERNAL
|
// @doc EXTERNAL
|
||||||
@ -390,7 +395,7 @@ public:
|
|||||||
// @base public | TObject
|
// @base public | TObject
|
||||||
class TExpression : public TObject
|
class TExpression : public TObject
|
||||||
|
|
||||||
// @author:(INTERNAL) Alex
|
// @author:(INTERNAL) Sandro
|
||||||
|
|
||||||
// @access:(INTERNAL) Private Member
|
// @access:(INTERNAL) Private Member
|
||||||
{
|
{
|
||||||
@ -449,20 +454,18 @@ protected: // TObject
|
|||||||
public:
|
public:
|
||||||
// @cmember Duplica l'espressione
|
// @cmember Duplica l'espressione
|
||||||
virtual TObject* dup() const;
|
virtual TObject* dup() const;
|
||||||
|
|
||||||
// @cmember Ritorna il valore real dell'espressione
|
|
||||||
const real& as_real();
|
|
||||||
// @cmember Ritorna il valore stringa dell'espressione
|
|
||||||
const TString& as_string();
|
|
||||||
// @cmember Ritorna il valore dell'espressione come booleano
|
|
||||||
bool as_bool();
|
|
||||||
|
|
||||||
// @cmember operator const | real& | | Ritorna il valore real dell'espressione
|
// @cmember operator const | real& | | Ritorna il valore real dell'espressione
|
||||||
operator const real&() {return as_real();}
|
operator const real&() {return as_real();}
|
||||||
// @cmember operator const | TString& | | Ritorna il valore dell'espressione come stringa
|
// @cmember operator const | char* | | Ritorna il valore dell'espressione come stringa
|
||||||
operator const TString &() {return as_string();}
|
operator const TString &() {return as_string();}
|
||||||
// @cmember Ritorna il valore dell'espressione come booleano
|
// @cmember Ritorna il valore dell'espressione come booleano
|
||||||
operator bool() {return as_bool();}
|
operator bool() {return as_bool();}
|
||||||
|
// @cmember operator const | real& | | Ritorna il valore real dell'espressione
|
||||||
|
const real & as_real();
|
||||||
|
// @cmember operator const | char* | | Ritorna il valore dell'espressione come stringa
|
||||||
|
const TString & as_string();
|
||||||
|
// @cmember Ritorna il valore dell'espressione come booleano
|
||||||
|
bool as_bool();
|
||||||
// @cmember Ritorna il nome della variabile di posto <p varnum>
|
// @cmember Ritorna il nome della variabile di posto <p varnum>
|
||||||
const char* varname(int varnum) const
|
const char* varname(int varnum) const
|
||||||
{ return _var.varname(varnum); }
|
{ return _var.varname(varnum); }
|
||||||
|
@ -2640,6 +2640,7 @@ const TString& TRectype::get_str(const char* fieldname) const
|
|||||||
static TFixed_string tmp(_isam_string, sizeof(_isam_string));
|
static TFixed_string tmp(_isam_string, sizeof(_isam_string));
|
||||||
const RecDes * recd = rec_des();
|
const RecDes * recd = rec_des();
|
||||||
const int nf = findfld(recd, fieldname);
|
const int nf = findfld(recd, fieldname);
|
||||||
|
const RecFieldDes& fd = recd->Fd[nf];
|
||||||
if (nf == FIELDERR)
|
if (nf == FIELDERR)
|
||||||
{
|
{
|
||||||
unknown_field(fieldname);
|
unknown_field(fieldname);
|
||||||
@ -2647,7 +2648,6 @@ const TString& TRectype::get_str(const char* fieldname) const
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const RecFieldDes& fd = recd->Fd[nf];
|
|
||||||
__getfieldbuff(fd.Len, fd.TypeF, _rec + fd.RecOff, _isam_string);
|
__getfieldbuff(fd.Len, fd.TypeF, _rec + fd.RecOff, _isam_string);
|
||||||
}
|
}
|
||||||
return tmp;
|
return tmp;
|
||||||
@ -2656,20 +2656,11 @@ const TString& TRectype::get_str(const char* fieldname) const
|
|||||||
#ifndef FOXPRO
|
#ifndef FOXPRO
|
||||||
|
|
||||||
const TString& TRectype::get(const char* fieldname) const
|
const TString& TRectype::get(const char* fieldname) const
|
||||||
|
{
|
||||||
|
if (_memo_data && type(fieldname) == _memofld)
|
||||||
{
|
{
|
||||||
const RecDes* recd = rec_des();
|
const RecDes* recd = rec_des();
|
||||||
const int index = findfld(recd, fieldname);
|
const int index = findfld(recd, fieldname);
|
||||||
if (index == FIELDERR)
|
|
||||||
{
|
|
||||||
unknown_field(fieldname);
|
|
||||||
return EMPTY_STRING;
|
|
||||||
}
|
|
||||||
|
|
||||||
const RecFieldDes& fd = recd->Fd[index];
|
|
||||||
const TFieldtypes ft = TFieldtypes(fd.TypeF);
|
|
||||||
|
|
||||||
if(ft == _memofld )
|
|
||||||
{
|
|
||||||
if ( _memo_data->objptr( index ) && (*_memo_dirty)[ index ] )
|
if ( _memo_data->objptr( index ) && (*_memo_dirty)[ index ] )
|
||||||
return _memo_data->row( index );
|
return _memo_data->row( index );
|
||||||
if( _memo_recno >= 0L )
|
if( _memo_recno >= 0L )
|
||||||
@ -2760,16 +2751,13 @@ void TRectype::put(const char* fieldname, int val)
|
|||||||
{
|
{
|
||||||
sprintf(_isam_string, "%d", val);
|
sprintf(_isam_string, "%d", val);
|
||||||
put_str( fieldname, _isam_string);
|
put_str( fieldname, _isam_string);
|
||||||
setempty(FALSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TRectype::put(const char* fieldname, long val)
|
void TRectype::put(const char* fieldname, long val)
|
||||||
|
|
||||||
{
|
{
|
||||||
sprintf(_isam_string, "%ld", val);
|
sprintf(_isam_string, "%ld", val);
|
||||||
put_str( fieldname, _isam_string);
|
put_str( fieldname, _isam_string);
|
||||||
setempty(FALSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TRectype::put(const char* fieldname, TTextfile& txt)
|
void TRectype::put(const char* fieldname, TTextfile& txt)
|
||||||
@ -2790,36 +2778,29 @@ void TRectype::put(const char* fieldname, TTextfile& txt)
|
|||||||
|
|
||||||
sprintf(_isam_string, "%ld", val);
|
sprintf(_isam_string, "%ld", val);
|
||||||
put_str( fieldname, _isam_string);
|
put_str( fieldname, _isam_string);
|
||||||
setempty(FALSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TRectype::put(const char* fieldname, word val)
|
void TRectype::put(const char* fieldname, word val)
|
||||||
|
|
||||||
{
|
{
|
||||||
sprintf(_isam_string, "%u", val);
|
sprintf(_isam_string, "%u", val);
|
||||||
put_str( fieldname, _isam_string);
|
put_str( fieldname, _isam_string);
|
||||||
setempty(FALSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TRectype::put(const char* fieldname, const real& val)
|
void TRectype::put(const char* fieldname, const real& val)
|
||||||
{
|
{
|
||||||
put_str( fieldname, val.string());
|
put_str( fieldname, val.string());
|
||||||
setempty(FALSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TRectype::put(const char* fieldname, const TDate& val)
|
void TRectype::put(const char* fieldname, const TDate& val)
|
||||||
{
|
{
|
||||||
put_str( fieldname, val.string(full));
|
put_str( fieldname, val.string(full));
|
||||||
setempty(FALSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TRectype::put(const char* fieldname, char val)
|
void TRectype::put(const char* fieldname, char val)
|
||||||
{
|
{
|
||||||
const char w[2] = {val, '\0'};
|
const char w[2] = {val, '\0'};
|
||||||
|
|
||||||
put_str( fieldname, w);
|
put_str( fieldname, w);
|
||||||
setempty(FALSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2827,7 +2808,6 @@ void TRectype::put(const char* fieldname, bool val)
|
|||||||
{
|
{
|
||||||
char s[2] = { val ? 'X' : ' ', '\0'};
|
char s[2] = { val ? 'X' : ' ', '\0'};
|
||||||
put_str( fieldname, s);
|
put_str( fieldname, s);
|
||||||
setempty(FALSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // FOXPRO
|
#endif // FOXPRO
|
||||||
@ -2865,7 +2845,6 @@ void TRectype::put_str(const char* fieldname, const char* val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TRectype::zero(const char* fieldname)
|
void TRectype::zero(const char* fieldname)
|
||||||
|
|
||||||
{
|
{
|
||||||
if (*_tab && strcmp(fieldname , "COD") == 0)
|
if (*_tab && strcmp(fieldname , "COD") == 0)
|
||||||
put("COD", _tab);
|
put("COD", _tab);
|
||||||
@ -3063,7 +3042,7 @@ TRecfield::TRecfield(TRectype& rec, const char* name, int from, int to)
|
|||||||
|
|
||||||
int TRecfield::operator =(int i)
|
int TRecfield::operator =(int i)
|
||||||
{
|
{
|
||||||
char buff[16];
|
char buff[32];
|
||||||
sprintf(buff, "%d", i);
|
sprintf(buff, "%d", i);
|
||||||
__putfieldbuff( _len, _dec, _type, buff, _p);
|
__putfieldbuff( _len, _dec, _type, buff, _p);
|
||||||
_rec->setempty(FALSE);
|
_rec->setempty(FALSE);
|
||||||
@ -3073,7 +3052,7 @@ int TRecfield::operator =(int i)
|
|||||||
|
|
||||||
long TRecfield::operator =(long l)
|
long TRecfield::operator =(long l)
|
||||||
{
|
{
|
||||||
char buff[16];
|
char buff[32];
|
||||||
sprintf(buff, "%ld", l);
|
sprintf(buff, "%ld", l);
|
||||||
__putfieldbuff( _len, _dec, _type, buff, _p);
|
__putfieldbuff( _len, _dec, _type, buff, _p);
|
||||||
_rec->setempty(FALSE);
|
_rec->setempty(FALSE);
|
||||||
|
@ -532,7 +532,6 @@ int TMask::id2pos(
|
|||||||
TMask_field& TMask::field(short id) const
|
TMask_field& TMask::field(short id) const
|
||||||
{
|
{
|
||||||
int pos = id2pos(id);
|
int pos = id2pos(id);
|
||||||
|
|
||||||
#ifdef DBG
|
#ifdef DBG
|
||||||
if (pos < 0)
|
if (pos < 0)
|
||||||
{
|
{
|
||||||
@ -540,10 +539,20 @@ TMask_field& TMask::field(short id) const
|
|||||||
pos = 0;
|
pos = 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return fld(pos);
|
return fld(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TMask_field* TMask::find_by_fieldname(const char* fieldname) const
|
||||||
|
{
|
||||||
|
for (int i = fields()-1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
TMask_field& f = fld(i);
|
||||||
|
const TFieldref* fr = f.field();
|
||||||
|
if (fr && fr->name() == fieldname)
|
||||||
|
return &f;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
TEdit_field& TMask::efield(short id) const
|
TEdit_field& TMask::efield(short id) const
|
||||||
{
|
{
|
||||||
|
@ -249,6 +249,8 @@ public:
|
|||||||
{ return (TMask_field&)_field[i]; }
|
{ return (TMask_field&)_field[i]; }
|
||||||
// @cmember Ritorna il campo contraddistinto dall'identificatore passato
|
// @cmember Ritorna il campo contraddistinto dall'identificatore passato
|
||||||
TMask_field& field(short id) const;
|
TMask_field& field(short id) const;
|
||||||
|
// @cmember Ritorna il campo corrispondente al FIELD fieldname
|
||||||
|
TMask_field* find_by_fieldname(const char* fieldname) const;
|
||||||
// @cmember Ritorna il campo di edit contraddistinto dall'identificatore passato
|
// @cmember Ritorna il campo di edit contraddistinto dall'identificatore passato
|
||||||
TEdit_field& efield(short id) const;
|
TEdit_field& efield(short id) const;
|
||||||
// @cmember Ritorna il campo sheet contraddistinto dall'identificatore passato
|
// @cmember Ritorna il campo sheet contraddistinto dall'identificatore passato
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include <colors.h>
|
#include <colors.h>
|
||||||
#include <controls.h>
|
#include <controls.h>
|
||||||
#include <execp.h>
|
#include <execp.h>
|
||||||
|
#include <expr.h>
|
||||||
#include <msksheet.h>
|
#include <msksheet.h>
|
||||||
#include <prefix.h>
|
#include <prefix.h>
|
||||||
#include <relation.h>
|
#include <relation.h>
|
||||||
@ -2765,8 +2766,6 @@ bool TEdit_field::parse_item(TScanner& scanner)
|
|||||||
{
|
{
|
||||||
const TString16 what(scanner.popkey());
|
const TString16 what(scanner.popkey());
|
||||||
const TBrowse* b = parse_browse(scanner);
|
const TBrowse* b = parse_browse(scanner);
|
||||||
|
|
||||||
CHECK(b,"Impossibile copiare la browse da un campo visto che quel campo non ce l'ha" );
|
|
||||||
if (b)
|
if (b)
|
||||||
{
|
{
|
||||||
if (what == "US" || what == "AL")
|
if (what == "US" || what == "AL")
|
||||||
@ -2783,6 +2782,8 @@ bool TEdit_field::parse_item(TScanner& scanner)
|
|||||||
return browse()->parse_copy(what, *b);
|
return browse()->parse_copy(what, *b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
NFCHECK("Il campo %d non puo' copiare la browse da chi non ce l'ha", _ctl_data._dlg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scanner.key() == "SH") // SHEET
|
if (scanner.key() == "SH") // SHEET
|
||||||
@ -3789,7 +3790,33 @@ const char* TCurrency_field::raw2win(const char* data) const
|
|||||||
const char* TCurrency_field::win2raw(const char* data) const
|
const char* TCurrency_field::win2raw(const char* data) const
|
||||||
{
|
{
|
||||||
TString& str = _ctl_data._park;
|
TString& str = _ctl_data._park;
|
||||||
const real num(real::ita2eng(data));
|
str = data;
|
||||||
|
str.strip("."); str.replace(',', '.');
|
||||||
|
bool is_formula = FALSE;
|
||||||
|
for (int i = 0; str[i]; i++)
|
||||||
|
{
|
||||||
|
if (strchr("0123456789.", str[i]) == NULL)
|
||||||
|
{
|
||||||
|
is_formula = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
real num;
|
||||||
|
if (is_formula)
|
||||||
|
{
|
||||||
|
TExpression e(str, _numexpr, TRUE);
|
||||||
|
for (int i = e.numvar()-1; i >= 0; i--)
|
||||||
|
{
|
||||||
|
TMask_field* f = mask().find_by_fieldname(e.varname(i));
|
||||||
|
if (f)
|
||||||
|
e.setvar(i, f->get());
|
||||||
|
}
|
||||||
|
num = e.as_real();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
num = real(str);
|
||||||
|
|
||||||
str = num.string();
|
str = num.string();
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
@ -3812,7 +3839,7 @@ bool TCurrency_field::on_key(KEY key)
|
|||||||
ok = !_flags.uppercase;
|
ok = !_flags.uppercase;
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
ok = strchr("0123456789.,", key) != NULL;
|
ok = strchr("0123456789.,+*-/()", key) != NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!ok)
|
if (!ok)
|
||||||
|
@ -1089,7 +1089,7 @@ bool TSpreadsheet::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
|
|||||||
TMask_field& button = sm.fld(button_pos);
|
TMask_field& button = sm.fld(button_pos);
|
||||||
if (button.active())
|
if (button.active())
|
||||||
{
|
{
|
||||||
// str2mask(_cur_rec); // Spostato sopra
|
str2mask(_cur_rec); // Non commentare!
|
||||||
button.on_hit();
|
button.on_hit();
|
||||||
if (sm.dirty())
|
if (sm.dirty())
|
||||||
{
|
{
|
||||||
|
@ -5,15 +5,14 @@
|
|||||||
#include <gm.h>
|
#include <gm.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <progind.h>
|
#include <currency.h>
|
||||||
#include <utility.h>
|
|
||||||
#include <tabutil.h>
|
#include <tabutil.h>
|
||||||
#include <printapp.h>
|
#include <printapp.h>
|
||||||
|
#include <progind.h>
|
||||||
#include <urldefid.h>
|
#include <urldefid.h>
|
||||||
|
#include <utility.h>
|
||||||
|
|
||||||
TLocalisamfile *fff;
|
const char* const printf_types = "dDiIuUoOxXfeEgGcCnNsSpPrRtTaAvV";
|
||||||
|
|
||||||
const char* const printf_types = "dDiIuUoOxXfeEgGcCnNsSpPrRtTaA";
|
|
||||||
|
|
||||||
// _FieldTok flags
|
// _FieldTok flags
|
||||||
|
|
||||||
@ -31,6 +30,7 @@ const word JUMP_FLAG = 0x0400;
|
|||||||
const word RECNO_FLAG = 0x0800;
|
const word RECNO_FLAG = 0x0800;
|
||||||
const word BOOLEAN_FLAG = 0x1000;
|
const word BOOLEAN_FLAG = 0x1000;
|
||||||
const word IGNORE_FILL = 0x2000;
|
const word IGNORE_FILL = 0x2000;
|
||||||
|
const word VALUTA_FLAG = 0x4000;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
// print token containers
|
// print token containers
|
||||||
@ -785,10 +785,10 @@ void TPrint_application::set_row (
|
|||||||
case 'u':
|
case 'u':
|
||||||
case 'r':
|
case 'r':
|
||||||
{
|
{
|
||||||
char *xxxx = new char[2];
|
char *x = new char[2];
|
||||||
xxxx[0] = ch;
|
x[0] = ch;
|
||||||
xxxx[1] = '\0';
|
x[1] = '\0';
|
||||||
_rows.add (new _FieldTok (_currow, xxxx, FONT_FLAG));
|
_rows.add (new _FieldTok (_currow, x, FONT_FLAG));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'g':
|
case 'g':
|
||||||
@ -834,7 +834,21 @@ void TPrint_application::set_row (
|
|||||||
flags |= IGNORE_FILL;
|
flags |= IGNORE_FILL;
|
||||||
// fall down
|
// fall down
|
||||||
case 'n':
|
case 'n':
|
||||||
|
if (_magic_currency)
|
||||||
|
{
|
||||||
|
if (size >= 9 && dec == 0 && _picture.find(',') < 0)
|
||||||
|
flags |= VALUTA_FLAG;
|
||||||
|
else
|
||||||
flags |= NUMBER_FLAG;
|
flags |= NUMBER_FLAG;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
flags |= NUMBER_FLAG;
|
||||||
|
break;
|
||||||
|
case 'V':
|
||||||
|
flags |= IGNORE_FILL;
|
||||||
|
// fall down
|
||||||
|
case 'v':
|
||||||
|
flags |= VALUTA_FLAG;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
CHECK (0, "TPrint_application::set_row: invalid @ code");
|
CHECK (0, "TPrint_application::set_row: invalid @ code");
|
||||||
@ -844,10 +858,11 @@ void TPrint_application::set_row (
|
|||||||
flags & DATE_FLAG ||
|
flags & DATE_FLAG ||
|
||||||
flags & TRANS_FLAG ||
|
flags & TRANS_FLAG ||
|
||||||
flags & BOOLEAN_FLAG ||
|
flags & BOOLEAN_FLAG ||
|
||||||
flags & STRING_FLAG)
|
flags & STRING_FLAG ||
|
||||||
|
flags & VALUTA_FLAG)
|
||||||
{
|
{
|
||||||
char *xxx = va_arg (params, char *);
|
char* x = va_arg (params, char *);
|
||||||
_rows.add (new _FieldTok (_currow, xxx, flags, align, size, dec));
|
_rows.add (new _FieldTok (_currow, x, flags, align, size, dec));
|
||||||
}
|
}
|
||||||
flags = 0x0000;
|
flags = 0x0000;
|
||||||
align = 'l';
|
align = 'l';
|
||||||
@ -933,10 +948,17 @@ void TPrint_application::set_row (
|
|||||||
case 'r': // Real
|
case 'r': // Real
|
||||||
{
|
{
|
||||||
const real& rrr = * va_arg (params, real *);
|
const real& rrr = * va_arg (params, real *);
|
||||||
if (_picture[0] && (formato.len() == 2 || formato == "%Lf"))
|
if (_picture.not_empty() && (formato.len() == 2 || formato == "%Lf"))
|
||||||
{
|
{
|
||||||
// no format specifications
|
// no format specifications
|
||||||
// use default picture
|
// use default picture
|
||||||
|
q.cut(0);
|
||||||
|
if (_magic_currency)
|
||||||
|
{
|
||||||
|
if (_picture == "." || (_picture.len() >= 9 && _picture.find(',') < 0))
|
||||||
|
real2currency(rrr, q);
|
||||||
|
}
|
||||||
|
if (q.empty())
|
||||||
q = rrr.string(_picture);
|
q = rrr.string(_picture);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1132,6 +1154,18 @@ bool TPrint_application::print_tree (link_item * head)
|
|||||||
return go;
|
return go;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TPrint_application::real2currency(const real& r, TString& str) const
|
||||||
|
{
|
||||||
|
TCurrency c(r, "_FIRM");
|
||||||
|
if (_curr_codval.not_empty())
|
||||||
|
c.change_value(_curr_codval);
|
||||||
|
const bool dotted = _picture.empty() || _picture.find('.') >= 0;
|
||||||
|
str = c.string(dotted);
|
||||||
|
const int len = _picture.len();
|
||||||
|
if (len >= 9)
|
||||||
|
str.right_just(len);
|
||||||
|
}
|
||||||
|
|
||||||
// @doc INTERNAL
|
// @doc INTERNAL
|
||||||
|
|
||||||
// @mfunc Stampa un singolo record
|
// @mfunc Stampa un singolo record
|
||||||
@ -1245,7 +1279,7 @@ bool TPrint_application::print_one (
|
|||||||
to = atoi ((const char *) ttt.get ());
|
to = atoi ((const char *) ttt.get ());
|
||||||
}
|
}
|
||||||
// get field val
|
// get field val
|
||||||
TLocalisamfile &f = _cur->file(ln);
|
const TRectype& f = _cur->curr(ln);
|
||||||
if (ft->_flags & TRANS_FLAG)
|
if (ft->_flags & TRANS_FLAG)
|
||||||
{
|
{
|
||||||
_Transfield *tr = NULL;
|
_Transfield *tr = NULL;
|
||||||
@ -1283,14 +1317,14 @@ bool TPrint_application::print_one (
|
|||||||
TString80 pict;
|
TString80 pict;
|
||||||
real r(f.get(fn));
|
real r(f.get(fn));
|
||||||
|
|
||||||
bool isreal = f.curr ().type (fn) == _realfld;
|
bool isreal = f.type(fn) == _realfld;
|
||||||
|
|
||||||
if (ft->_flags & PICTURE_FLAG)
|
if (ft->_flags & PICTURE_FLAG)
|
||||||
pict = pic;
|
pict = pic;
|
||||||
else if (!(ft->_flags & DEC_FLAG) && *_picture && isreal)
|
else if (!(ft->_flags & DEC_FLAG) && _picture.not_empty() && isreal)
|
||||||
pict = _picture;
|
pict = _picture;
|
||||||
|
|
||||||
if (pict.len () > 0)
|
if (pict.not_empty())
|
||||||
toprint = r.string (pict);
|
toprint = r.string (pict);
|
||||||
else if (ft->_flags & DEC_FLAG)
|
else if (ft->_flags & DEC_FLAG)
|
||||||
toprint = r.string (ft->_size, ft->_dec);
|
toprint = r.string (ft->_size, ft->_dec);
|
||||||
@ -1302,13 +1336,18 @@ bool TPrint_application::print_one (
|
|||||||
}
|
}
|
||||||
else if (ft->_flags & STRING_FLAG)
|
else if (ft->_flags & STRING_FLAG)
|
||||||
{
|
{
|
||||||
toprint = f.curr().get (fn);
|
toprint = f.get (fn);
|
||||||
// perform string extraction
|
// perform string extraction
|
||||||
if (from != -1)
|
if (from != -1)
|
||||||
toprint = toprint.sub (from, to);
|
toprint = toprint.sub (from, to);
|
||||||
else if (to != -1)
|
else if (to != -1)
|
||||||
toprint = toprint.left (to);
|
toprint = toprint.left (to);
|
||||||
}
|
}
|
||||||
|
else if (ft->_flags & VALUTA_FLAG)
|
||||||
|
{
|
||||||
|
const real n = f.get(fn);
|
||||||
|
real2currency(n, toprint);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// adjust size and set fill char
|
// adjust size and set fill char
|
||||||
if (ft->_flags & PAD_FLAG)
|
if (ft->_flags & PAD_FLAG)
|
||||||
@ -1406,7 +1445,7 @@ bool TPrint_application::print_one (
|
|||||||
case 'r':
|
case 'r':
|
||||||
{
|
{
|
||||||
const real& rrr = *(real*)pr->_what;
|
const real& rrr = *(real*)pr->_what;
|
||||||
if (pr->_fmt.len () == 2 && *_picture)
|
if (pr->_fmt.len () == 2 && _picture.not_empty())
|
||||||
{
|
{
|
||||||
strcpy (__tmp_string, rrr.string (_picture));
|
strcpy (__tmp_string, rrr.string (_picture));
|
||||||
}
|
}
|
||||||
@ -1552,9 +1591,9 @@ TPrint_application::TPrint_application ():TApplication (), _transtab (10),
|
|||||||
_print_defined = FALSE;
|
_print_defined = FALSE;
|
||||||
_force_progind = FALSE;
|
_force_progind = FALSE;
|
||||||
_force_setpage = FALSE;
|
_force_setpage = FALSE;
|
||||||
|
_magic_currency = FALSE;
|
||||||
_prind = NULL;
|
_prind = NULL;
|
||||||
_cur_file = 0;
|
_cur_file = 0;
|
||||||
_picture = "";
|
|
||||||
_print_zero = FALSE;
|
_print_zero = FALSE;
|
||||||
_last_choice = BAR_ITEM (1);
|
_last_choice = BAR_ITEM (1);
|
||||||
}
|
}
|
||||||
|
@ -181,7 +181,12 @@ class TPrint_application : public TApplication
|
|||||||
// @cmember:(INTERNAL) Barra di attesa
|
// @cmember:(INTERNAL) Barra di attesa
|
||||||
TProgind* _prind;
|
TProgind* _prind;
|
||||||
// @cmember:(INTERNAL) Picture default per i reali
|
// @cmember:(INTERNAL) Picture default per i reali
|
||||||
const char* _picture;
|
TString80 _picture;
|
||||||
|
|
||||||
|
// @cmember:(INTERNAL) Valuta di stampa per TCurrency
|
||||||
|
TString16 _curr_codval;
|
||||||
|
// @cmember:(INTERNAL) Trasforma i real in TCurrency se necessario
|
||||||
|
bool _magic_currency;
|
||||||
|
|
||||||
// @cmember:(INTERNAL) Ultima scelta di menù
|
// @cmember:(INTERNAL) Ultima scelta di menù
|
||||||
MENU_TAG _last_choice;
|
MENU_TAG _last_choice;
|
||||||
@ -303,6 +308,9 @@ public:
|
|||||||
// @cmember Setta un segnalibro nell'anteprima di stampa
|
// @cmember Setta un segnalibro nell'anteprima di stampa
|
||||||
int set_bookmark(const char* txt, int father = -1);
|
int set_bookmark(const char* txt, int father = -1);
|
||||||
|
|
||||||
|
// @cmember Converte un real nella stringa generata da un currency
|
||||||
|
void real2currency(const real& r, TString& str) const;
|
||||||
|
|
||||||
// @cmember Permette di trovare un link ipertestuale
|
// @cmember Permette di trovare un link ipertestuale
|
||||||
int find_link(const char* descr) const;
|
int find_link(const char* descr) const;
|
||||||
// @cmember Permette di abilitare determinati colori come indicatori di legame ipertestuale
|
// @cmember Permette di abilitare determinati colori come indicatori di legame ipertestuale
|
||||||
@ -394,6 +402,23 @@ public:
|
|||||||
// @cmember Setta la picture default per i reali
|
// @cmember Setta la picture default per i reali
|
||||||
void set_real_picture(const char* p)
|
void set_real_picture(const char* p)
|
||||||
{ _picture = p; }
|
{ _picture = p; }
|
||||||
|
|
||||||
|
// @cmember Ritorna la picture default per i reali
|
||||||
|
const TString& get_real_picture() const
|
||||||
|
{ return _picture; }
|
||||||
|
|
||||||
|
// @cmember Setta la valuta con cui stampare i Currency
|
||||||
|
void set_curr_codval(const char* cv)
|
||||||
|
{ _curr_codval = cv; }
|
||||||
|
|
||||||
|
// @cmember Ritorna la valuta con cui stampare i Currency
|
||||||
|
const TString& get_curr_codval() const
|
||||||
|
{ return _curr_codval; }
|
||||||
|
|
||||||
|
// @cmember Setta il flag di TCurrency automatici
|
||||||
|
void set_magic_currency(bool mc)
|
||||||
|
{ _magic_currency = mc; }
|
||||||
|
|
||||||
// @cmember Permette di stampare (<p b>=TRUE) o di non stampare (<p b>=FALSE) il valore 0
|
// @cmember Permette di stampare (<p b>=TRUE) o di non stampare (<p b>=FALSE) il valore 0
|
||||||
// nel caso di campo vuoto.
|
// nel caso di campo vuoto.
|
||||||
void set_print_zero(bool b = TRUE)
|
void set_print_zero(bool b = TRUE)
|
||||||
|
@ -545,6 +545,7 @@ int TRelation_application::delete_mode()
|
|||||||
tab1 += 5;
|
tab1 += 5;
|
||||||
tab2 += tab1+2;
|
tab2 += tab1+2;
|
||||||
|
|
||||||
|
cur = 0L;
|
||||||
TCursor_sheet sht(&cur, items, "Eliminazione", head, 0x4, y);
|
TCursor_sheet sht(&cur, items, "Eliminazione", head, 0x4, y);
|
||||||
|
|
||||||
y = -1; // Posizione del campo precedente
|
y = -1; // Posizione del campo precedente
|
||||||
@ -578,10 +579,13 @@ int TRelation_application::delete_mode()
|
|||||||
sht.add_string(id+1000, 0, "A ", tab2, y, e.size(), flags);
|
sht.add_string(id+1000, 0, "A ", tab2, y, e.size(), flags);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (y == 0)
|
||||||
|
sht.first_focus(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int tasto;
|
int tasto;
|
||||||
|
sht.open();
|
||||||
while ((tasto = sht.run()) == K_ENTER)
|
while ((tasto = sht.run()) == K_ENTER)
|
||||||
{
|
{
|
||||||
TRectype rec_from(cur.file().num()), rec_to(cur.file().num());
|
TRectype rec_from(cur.file().num()), rec_to(cur.file().num());
|
||||||
@ -605,15 +609,13 @@ int TRelation_application::delete_mode()
|
|||||||
++cur;
|
++cur;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sht.close();
|
||||||
|
|
||||||
if (tasto == K_DEL)
|
if (tasto == K_DEL)
|
||||||
{
|
{
|
||||||
long deleting = sht.checked();
|
long deleting = sht.checked();
|
||||||
if (deleting == 0)
|
if (deleting > 0)
|
||||||
{
|
{
|
||||||
sht.check(sht.selected());
|
|
||||||
deleting++;
|
|
||||||
}
|
|
||||||
TString msg;
|
TString msg;
|
||||||
msg = "Confermate l'eliminazione de";
|
msg = "Confermate l'eliminazione de";
|
||||||
if (deleting == 1)
|
if (deleting == 1)
|
||||||
@ -666,6 +668,9 @@ int TRelation_application::delete_mode()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
error_box("Non e' stato selezionato nessun documento");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user