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:
guy 1998-12-22 10:40:23 +00:00
parent d4ca44125c
commit e2a275e3ba
11 changed files with 359 additions and 300 deletions

View File

@ -71,7 +71,7 @@ TObject* TDowJones::rec2obj(const TRectype& rec) const
if (data->_den <= ZERO)
{
NFCHECK("Codice valuta assente");
NFCHECK("Codice valuta non valido '%s'", (const char*)rec.get("CODTAB"));
data->_den = 1.0;
data->_num = 1.0;
}

View File

@ -1,18 +1,13 @@
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#define __EXPR_CPP
#include <expr.h>
#include <stack.h>
#include <utility.h>
#include <date.h>
TValue::TValue(const real& val)
{
_r = val;
_s = val.string();
_t = _numexpr;
}
void TCodearray::clear()
{
destroy();
@ -51,55 +46,54 @@ void TVararray::add(const char* name, const TValue& 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);
CHECKS(var, "Variabile NULLA ", name);
if (strcmp(var->getname(), name) == 0)
{
*var = val;
break;
return;
}
}
NFCHECK("Variabile non trovata: %s", name);
}
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);
CHECKS(var, "Variabile NULLA ", name);
if (strcmp(var->getname(), name) == 0)
{
*var = val;
break;
return;
}
}
NFCHECK("Variabile non trovata: %s", name);
}
const real& TVararray::getnum(const char* name)
{
for (int i = items()-1; i >= 0; i--)
{
const TVar* var = (const TVar*)objptr(i);
if (strcmp(var->getname(), name) == 0)
TVar* var = (TVar*)objptr(i);
if (var && strcmp(var->getname(), name) == 0)
return var->number();
}
NFCHECK("Unknown variable: %s", name);
return ZERO;
}
const real& TVararray::getnum(int varnum)
{
const TVar* var = (const TVar*)objptr(varnum);
if (var == NULL)
if (varnum < 0 || varnum >= items())
{
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--)
{
const TVar* var = (TVar*)objptr(i);
if (strcmp(var->getname(), name) == 0)
TVar* var = (TVar*)objptr(i);
if (var && strcmp(var->getname(), name) == 0)
return var->string();
}
NFCHECK("Unknown variable : %s", name);
return EMPTY_STRING;
return "";
}
const TString& TVararray::getstring(int varnum)
{
const TVar* var = (const TVar*)objptr(varnum);
if (var == NULL)
if (varnum < 0 || varnum >= items())
{
NFCHECK("Invalid variable number : %d", varnum);
return EMPTY_STRING;
return "";
}
TVar* var = (TVar*)objptr(varnum);
return var->string();
}
@ -130,100 +125,86 @@ const TString& TVararray::getstring(int varnum)
// 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)
{
if (_data.items() > _sp)
if (_sp < _data.items())
{
_sp++;
peek_real() = r;
}
else
TStack::push(r);
TStack::push(new TValue(r));
}
void TEval_stack::push(const TString& s)
{
if (_data.items() > _sp)
if (_sp < _data.items())
{
_sp++;
peek_string() = s;
}
else
TStack::push(s);
TStack::push(new TValue(s));
}
void TEval_stack::push(const char* s)
{
if (_data.items() > _sp)
if (_sp < _data.items())
{
_sp++;
peek_string() = s;
}
else
TStack::push(new TString80(s));
TStack::push(new TValue(s));
}
real& TEval_stack::pop_real()
{
TObject& o = pop();
if (o.class_id() == CLASS_STRING)
{
real* r = new real((TString&)o);
TStack::push(r);
return (real&)pop();
}
return (real&)o;
TValue& o = (TValue&)pop();
return o.number();
}
real& TEval_stack::peek_real()
{
TObject& o = peek(0);
if (o.class_id() == CLASS_STRING)
{
pop();
real* r = new real((TString&)o);
TStack::push(r);
return *r;
}
return (real&)o;
TValue& o = (TValue&)peek(0);
return o.number();
}
TString& TEval_stack::pop_string()
{
TObject& o = pop();
if (o.class_id() == CLASS_STRING)
return (TString&)o;
TString* s = new TString80(((real&)o).string());
TStack::push(s);
return (TString&)pop();
TValue& o = (TValue&)pop();
return o.string();
}
TString& TEval_stack::peek_string()
{
TObject& o = peek();
if (o.class_id() == CLASS_STRING)
return (TString&)o;
pop();
TString* s = new TString80(((real&)o).string());
TStack::push(s);
return *s;
TValue& o = (TValue&)peek(0);
return o.string();
}
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
///////////////////////////////////////////////////////////
@ -234,7 +215,6 @@ TExpression::TExpression(const char* expression, TTypeexp type, bool ignore_err)
{
_ignore_error=ignore_err;
_error=0;
_val = ZERO;
_dirty = TRUE;
_type = type;
compile(_original, type);
@ -246,7 +226,6 @@ TExpression::TExpression(TTypeexp type, bool ignore_err)
{
_ignore_error=ignore_err;
_error=0;
_val = ZERO;
_dirty = FALSE;
_type = type;
_code.clear();
@ -269,8 +248,7 @@ TObject* TExpression::dup() const
const real & TExpression::as_real()
{
if (user_func_dirty() || _dirty)
eval();
if (user_func_dirty() || _dirty) eval();
_dirty = FALSE;
return _val.number();
}
@ -296,13 +274,11 @@ void TExpression::evaluate_user_func(int index, int nparms, TEval_stack& stack,
NFCHECK("Unknown function %d.", index);
for ( int i = nparms ; i > 0; i--)
stack.pop();
if (curtype == _numexpr)
stack.push(ZERO);
else
stack.push("");
}
void TExpression::setvar(const char* varname, const real& 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)
{
if (_var.getnum(varnum) != val)
{
@ -422,13 +399,11 @@ void TExpression::eval()
if (r.is_zero())
{
if (!evalstack.peek_real().is_zero())
{
if (_ignore_error)
_error=1;
if (!_ignore_error)
print_error("Divisione per zero!");
}
}
else
print_error("Divisione per zero!");
} else
evalstack.peek_real() /= r;
}
break;
@ -440,16 +415,16 @@ void TExpression::eval()
break;
case _and:
{
const bool r2 = evalstack.pop_bool();
const bool r1 = evalstack.pop_bool();
evalstack.push(real(r1 && r2 ? 1.0 : 0.0));
const real & r2 = evalstack.pop_real();
real & r1 = evalstack.peek_real();
r1 = (!r1.is_zero() && !r2.is_zero()) ? 1.0 : 0.0;
}
break;
case _or:
{
const bool r2 = evalstack.pop_bool();
const bool r1 = evalstack.pop_bool();
evalstack.push(real(r1 || r2 ? 1.0 : 0.0));
const real & r2 = evalstack.pop_real();
real & r1 = evalstack.peek_real();
r1 = (r1 != ZERO || r2 != ZERO) ? 1.0 : 0.0;
}
break;
case _not:
@ -463,7 +438,7 @@ void TExpression::eval()
{
const TString & s2 = evalstack.pop_string();
const TString & s1 = evalstack.pop_string();
evalstack.push(real(s1 == s2 ? 1.0 : 0.0));
evalstack.push(s1 == s2);
}
else
{
@ -476,7 +451,7 @@ void TExpression::eval()
{
const TString & s2 = 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;
case _noteq:
@ -484,7 +459,7 @@ void TExpression::eval()
{
const TString & s2 = evalstack.pop_string();
TString & s1 = evalstack.pop_string();
evalstack.push(real(s1 != s2 ? 1.0 : 0.0));
evalstack.push(s1 != s2);
}
else
{
@ -498,7 +473,7 @@ void TExpression::eval()
{
const TString & s2 = evalstack.pop_string();
const TString & s1 = evalstack.pop_string();
evalstack.push(real(s1 < s2 ? 1.0 : 0.0));
evalstack.push(s1 < s2);
}
else
{
@ -512,7 +487,7 @@ void TExpression::eval()
{
const TString & s2 = evalstack.pop_string();
const TString & s1 = evalstack.pop_string();
evalstack.push(real(s1 > s2 ? 1.0 : 0.0));
evalstack.push(s1 > s2);
}
else
{
@ -526,7 +501,7 @@ void TExpression::eval()
{
const TString& s2 = evalstack.pop_string();
const TString& s1 = evalstack.pop_string();
evalstack.push(real(s1 <= s2 ? 1.0 : 0.0));
evalstack.push(s1 <= s2);
}
else
{
@ -540,7 +515,7 @@ void TExpression::eval()
{
const TString& s2 = evalstack.pop_string();
const TString& s1 = evalstack.pop_string();
evalstack.push(real(s1 >= s2 ? 1.0 : 0.0));
evalstack.push(s1 >= s2);
}
else
{
@ -562,8 +537,9 @@ void TExpression::eval()
real& r = evalstack.peek_real();
if (r < ZERO)
{
if (_ignore_error)
_error=1;
if (!_ignore_error)
else
print_error("Radice negativa!");
r = -r;
}
@ -630,7 +606,7 @@ void TExpression::eval()
case _len:
{
TString& s1 = evalstack.pop_string();
evalstack.push(real(s1.len()));
evalstack.push(s1.len());
}
break;
case _pow:
@ -700,8 +676,8 @@ void TExpression::eval()
{
const TString & s1 = evalstack.pop_string();
const TString & s2 = evalstack.pop_string();
const bool cond = evalstack.pop_bool();
evalstack.push(cond ? s2 : s1);
const real & cond = evalstack.pop_real();
evalstack.push(cond.is_zero() ? s1 : s2);
}
else
{
@ -747,14 +723,9 @@ void TExpression::eval()
}
}
// L'espressione non e' vuota
// Lo stack non e' vuoto
if (_code.items() > 1)
{
if (_type == _strexpr)
_val = evalstack.pop_string();
else
_val = evalstack.pop_real();
}
_val = (const TValue&)evalstack.pop();
else
_val = ZERO;
}
@ -1061,8 +1032,7 @@ TCodesym TExpression::__factor(TCodesym startsym)
else
{
_code.add(_number, real(__parms_found));
TString16 str; str.format("%d", index);
val.set(str);
val.set(format("%d", index));
_code.add(startsym, val);
_user_func_defined = TRUE;
}
@ -1191,11 +1161,11 @@ bool TExpression::set(const char* expression, TTypeexp type)
bool TExpression::compile(const TString& expression, TTypeexp type)
{
_error=0;
_user_func_defined = FALSE;
_s = expression;
_type = type;
_val = ZERO;
_val = real(0.0);
_code.clear();
if (expression.blank())
return TRUE;
@ -1210,7 +1180,7 @@ bool TExpression::compile(const TString& expression, TTypeexp type)
if (!_ignore_error)
{
TString msg;
msg << "Wrong expression : " << _original;
msg << "Espressione errata : " << _original;
print_error(msg);
}
}

View File

@ -83,15 +83,14 @@ enum TCodesym {
//
// @base public | TObject
class TValue : public TObject
// @author:(INTERNAL) Sandro
// @author:(INTERNAL) Alex
{
// @access:(INTERNAL) Private Member
// @cmember:(INTERNAL) Valore real
real _r;
// @cmember:(INTERNAL) Valore in formato stringa
TString80 _s;
TString256 _s;
// @cmember:(INTERNAL) Tipo preferito
TTypeexp _t;
@ -102,35 +101,40 @@ public:
{ _s = val._s; _r = val._r; _t = val._t; return *this; }
// @cmember Assegnamento di una stringa
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
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
const real& number() const
{ return _r; }
real& number()
{ if (_t == _strexpr) { _r = real(_s); _t = _numexpr; } return _r; }
// @cmember Ritorna il valore come stringa
const TString& string() const
{ return _s;}
TString& string()
{ if (_t == _numexpr) { _s = _r.string(); _t = _strexpr; } return _s; }
// @cmember Setta il valore passato come real
void set(const real& val)
{ _r = val; _s = val.string(); _t = _numexpr; }
{ _r = val; _t = _numexpr; }
// @cmember Setta il valore passato come stringa
void set(const char* val)
{ _s = val; _r = real(val); _t = _strexpr; }
{ _s = val; _t = _strexpr; }
// @cmember Setta il valore passato come stringa
TTypeexp type() const { return _t; }
// @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
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
TValue(const TValue& val)
{ *this = val; }
// @cmember Costruttore. Inizializza TValue a 0,0 e ""
TValue()
{ _r = 0.00; _s = ""; }
{ }
// @cmember Distruttore
virtual ~TValue()
{}
@ -176,10 +180,10 @@ public:
TCodesym getsym() const
{ return _sym;}
// @cmember Ritorna il valore come <c real>
const real& number() const
real& number()
{ return _val.number(); }
// @cmember Ritorna il valore come stringa
const TString& string() const
TString& string()
{ return _val.string(); }
// @cmember Costruttore, inizializza simbolo con "invalid", valore a nullvalue
@ -206,7 +210,7 @@ public:
// @base public | TArray
class TCodearray : public TArray
// @author:(INTERNAL) Alex
// @author:(INTERNAL) Sandro
// @access:(INTERNAL) Private Member
{
@ -254,7 +258,7 @@ class TVar : public TObject
{
// @cmember:(INTERNAL) Nome della variabile
TString80 _name;
TString _name;
// @cmember:(INTERNAL) Valore assegnato alla variabile
TValue _val;
@ -289,10 +293,10 @@ public:
operator TValue&()
{ return _val;}
// @cmember Ritorna il valore real della variabile
const real& number() const
real& number()
{ return _val.number(); }
// @cmember Ritorna il valore stringa della variabile
const TString& string() const
TString& string()
{ return _val.string();}
// @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
{
public:
void push(const real& r);
void push(const TString& s);
void push(const char* s);
real& pop_real();
real& peek_real();
TString& pop_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
@ -390,7 +395,7 @@ public:
// @base public | TObject
class TExpression : public TObject
// @author:(INTERNAL) Alex
// @author:(INTERNAL) Sandro
// @access:(INTERNAL) Private Member
{
@ -449,20 +454,18 @@ protected: // TObject
public:
// @cmember Duplica l'espressione
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
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();}
// @cmember Ritorna il valore dell'espressione come booleano
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>
const char* varname(int varnum) const
{ return _var.varname(varnum); }

View File

@ -2640,6 +2640,7 @@ const TString& TRectype::get_str(const char* fieldname) const
static TFixed_string tmp(_isam_string, sizeof(_isam_string));
const RecDes * recd = rec_des();
const int nf = findfld(recd, fieldname);
const RecFieldDes& fd = recd->Fd[nf];
if (nf == FIELDERR)
{
unknown_field(fieldname);
@ -2647,7 +2648,6 @@ const TString& TRectype::get_str(const char* fieldname) const
}
else
{
const RecFieldDes& fd = recd->Fd[nf];
__getfieldbuff(fd.Len, fd.TypeF, _rec + fd.RecOff, _isam_string);
}
return tmp;
@ -2656,20 +2656,11 @@ const TString& TRectype::get_str(const char* fieldname) const
#ifndef FOXPRO
const TString& TRectype::get(const char* fieldname) const
{
if (_memo_data && type(fieldname) == _memofld)
{
const RecDes* recd = rec_des();
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 ] )
return _memo_data->row( index );
if( _memo_recno >= 0L )
@ -2760,16 +2751,13 @@ void TRectype::put(const char* fieldname, int val)
{
sprintf(_isam_string, "%d", val);
put_str( fieldname, _isam_string);
setempty(FALSE);
}
void TRectype::put(const char* fieldname, long val)
{
sprintf(_isam_string, "%ld", val);
put_str( fieldname, _isam_string);
setempty(FALSE);
}
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);
put_str( fieldname, _isam_string);
setempty(FALSE);
}
void TRectype::put(const char* fieldname, word val)
{
sprintf(_isam_string, "%u", val);
put_str( fieldname, _isam_string);
setempty(FALSE);
}
void TRectype::put(const char* fieldname, const real& val)
{
put_str( fieldname, val.string());
setempty(FALSE);
}
void TRectype::put(const char* fieldname, const TDate& val)
{
put_str( fieldname, val.string(full));
setempty(FALSE);
}
void TRectype::put(const char* fieldname, char val)
{
const char w[2] = {val, '\0'};
put_str( fieldname, w);
setempty(FALSE);
}
@ -2827,7 +2808,6 @@ void TRectype::put(const char* fieldname, bool val)
{
char s[2] = { val ? 'X' : ' ', '\0'};
put_str( fieldname, s);
setempty(FALSE);
}
#endif // FOXPRO
@ -2865,7 +2845,6 @@ void TRectype::put_str(const char* fieldname, const char* val)
}
void TRectype::zero(const char* fieldname)
{
if (*_tab && strcmp(fieldname , "COD") == 0)
put("COD", _tab);
@ -3063,7 +3042,7 @@ TRecfield::TRecfield(TRectype& rec, const char* name, int from, int to)
int TRecfield::operator =(int i)
{
char buff[16];
char buff[32];
sprintf(buff, "%d", i);
__putfieldbuff( _len, _dec, _type, buff, _p);
_rec->setempty(FALSE);
@ -3073,7 +3052,7 @@ int TRecfield::operator =(int i)
long TRecfield::operator =(long l)
{
char buff[16];
char buff[32];
sprintf(buff, "%ld", l);
__putfieldbuff( _len, _dec, _type, buff, _p);
_rec->setempty(FALSE);

View File

@ -532,7 +532,6 @@ int TMask::id2pos(
TMask_field& TMask::field(short id) const
{
int pos = id2pos(id);
#ifdef DBG
if (pos < 0)
{
@ -540,10 +539,20 @@ TMask_field& TMask::field(short id) const
pos = 0;
}
#endif
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
{

View File

@ -249,6 +249,8 @@ public:
{ return (TMask_field&)_field[i]; }
// @cmember Ritorna il campo contraddistinto dall'identificatore passato
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
TEdit_field& efield(short id) const;
// @cmember Ritorna il campo sheet contraddistinto dall'identificatore passato

View File

@ -1,6 +1,7 @@
#include <colors.h>
#include <controls.h>
#include <execp.h>
#include <expr.h>
#include <msksheet.h>
#include <prefix.h>
#include <relation.h>
@ -2765,8 +2766,6 @@ bool TEdit_field::parse_item(TScanner& scanner)
{
const TString16 what(scanner.popkey());
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 (what == "US" || what == "AL")
@ -2783,6 +2782,8 @@ bool TEdit_field::parse_item(TScanner& scanner)
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
@ -3789,7 +3790,33 @@ const char* TCurrency_field::raw2win(const char* data) const
const char* TCurrency_field::win2raw(const char* data) const
{
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();
return str;
}
@ -3812,7 +3839,7 @@ bool TCurrency_field::on_key(KEY key)
ok = !_flags.uppercase;
break;
default :
ok = strchr("0123456789.,", key) != NULL;
ok = strchr("0123456789.,+*-/()", key) != NULL;
break;
}
if (!ok)

View File

@ -1089,7 +1089,7 @@ bool TSpreadsheet::event_handler(XI_OBJ* itf, XI_EVENT *xiev)
TMask_field& button = sm.fld(button_pos);
if (button.active())
{
// str2mask(_cur_rec); // Spostato sopra
str2mask(_cur_rec); // Non commentare!
button.on_hit();
if (sm.dirty())
{

View File

@ -5,15 +5,14 @@
#include <gm.h>
#endif
#include <progind.h>
#include <utility.h>
#include <currency.h>
#include <tabutil.h>
#include <printapp.h>
#include <progind.h>
#include <urldefid.h>
#include <utility.h>
TLocalisamfile *fff;
const char* const printf_types = "dDiIuUoOxXfeEgGcCnNsSpPrRtTaA";
const char* const printf_types = "dDiIuUoOxXfeEgGcCnNsSpPrRtTaAvV";
// _FieldTok flags
@ -31,6 +30,7 @@ const word JUMP_FLAG = 0x0400;
const word RECNO_FLAG = 0x0800;
const word BOOLEAN_FLAG = 0x1000;
const word IGNORE_FILL = 0x2000;
const word VALUTA_FLAG = 0x4000;
///////////////////////////////////////////////////////////
// print token containers
@ -785,10 +785,10 @@ void TPrint_application::set_row (
case 'u':
case 'r':
{
char *xxxx = new char[2];
xxxx[0] = ch;
xxxx[1] = '\0';
_rows.add (new _FieldTok (_currow, xxxx, FONT_FLAG));
char *x = new char[2];
x[0] = ch;
x[1] = '\0';
_rows.add (new _FieldTok (_currow, x, FONT_FLAG));
}
break;
case 'g':
@ -834,7 +834,21 @@ void TPrint_application::set_row (
flags |= IGNORE_FILL;
// fall down
case 'n':
if (_magic_currency)
{
if (size >= 9 && dec == 0 && _picture.find(',') < 0)
flags |= VALUTA_FLAG;
else
flags |= NUMBER_FLAG;
}
else
flags |= NUMBER_FLAG;
break;
case 'V':
flags |= IGNORE_FILL;
// fall down
case 'v':
flags |= VALUTA_FLAG;
break;
default:
CHECK (0, "TPrint_application::set_row: invalid @ code");
@ -844,10 +858,11 @@ void TPrint_application::set_row (
flags & DATE_FLAG ||
flags & TRANS_FLAG ||
flags & BOOLEAN_FLAG ||
flags & STRING_FLAG)
flags & STRING_FLAG ||
flags & VALUTA_FLAG)
{
char *xxx = va_arg (params, char *);
_rows.add (new _FieldTok (_currow, xxx, flags, align, size, dec));
char* x = va_arg (params, char *);
_rows.add (new _FieldTok (_currow, x, flags, align, size, dec));
}
flags = 0x0000;
align = 'l';
@ -933,10 +948,17 @@ void TPrint_application::set_row (
case 'r': // 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
// 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);
}
else
@ -1132,6 +1154,18 @@ bool TPrint_application::print_tree (link_item * head)
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
// @mfunc Stampa un singolo record
@ -1245,7 +1279,7 @@ bool TPrint_application::print_one (
to = atoi ((const char *) ttt.get ());
}
// get field val
TLocalisamfile &f = _cur->file(ln);
const TRectype& f = _cur->curr(ln);
if (ft->_flags & TRANS_FLAG)
{
_Transfield *tr = NULL;
@ -1283,14 +1317,14 @@ bool TPrint_application::print_one (
TString80 pict;
real r(f.get(fn));
bool isreal = f.curr ().type (fn) == _realfld;
bool isreal = f.type(fn) == _realfld;
if (ft->_flags & PICTURE_FLAG)
pict = pic;
else if (!(ft->_flags & DEC_FLAG) && *_picture && isreal)
else if (!(ft->_flags & DEC_FLAG) && _picture.not_empty() && isreal)
pict = _picture;
if (pict.len () > 0)
if (pict.not_empty())
toprint = r.string (pict);
else if (ft->_flags & DEC_FLAG)
toprint = r.string (ft->_size, ft->_dec);
@ -1302,13 +1336,18 @@ bool TPrint_application::print_one (
}
else if (ft->_flags & STRING_FLAG)
{
toprint = f.curr().get (fn);
toprint = f.get (fn);
// perform string extraction
if (from != -1)
toprint = toprint.sub (from, to);
else if (to != -1)
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
if (ft->_flags & PAD_FLAG)
@ -1406,7 +1445,7 @@ bool TPrint_application::print_one (
case 'r':
{
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));
}
@ -1552,9 +1591,9 @@ TPrint_application::TPrint_application ():TApplication (), _transtab (10),
_print_defined = FALSE;
_force_progind = FALSE;
_force_setpage = FALSE;
_magic_currency = FALSE;
_prind = NULL;
_cur_file = 0;
_picture = "";
_print_zero = FALSE;
_last_choice = BAR_ITEM (1);
}

View File

@ -181,7 +181,12 @@ class TPrint_application : public TApplication
// @cmember:(INTERNAL) Barra di attesa
TProgind* _prind;
// @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ù
MENU_TAG _last_choice;
@ -303,6 +308,9 @@ public:
// @cmember Setta un segnalibro nell'anteprima di stampa
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
int find_link(const char* descr) const;
// @cmember Permette di abilitare determinati colori come indicatori di legame ipertestuale
@ -394,6 +402,23 @@ public:
// @cmember Setta la picture default per i reali
void set_real_picture(const char* 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
// nel caso di campo vuoto.
void set_print_zero(bool b = TRUE)

View File

@ -545,6 +545,7 @@ int TRelation_application::delete_mode()
tab1 += 5;
tab2 += tab1+2;
cur = 0L;
TCursor_sheet sht(&cur, items, "Eliminazione", head, 0x4, y);
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);
break;
}
if (y == 0)
sht.first_focus(id);
}
}
int tasto;
sht.open();
while ((tasto = sht.run()) == K_ENTER)
{
TRectype rec_from(cur.file().num()), rec_to(cur.file().num());
@ -605,15 +609,13 @@ int TRelation_application::delete_mode()
++cur;
}
}
sht.close();
if (tasto == K_DEL)
{
long deleting = sht.checked();
if (deleting == 0)
if (deleting > 0)
{
sht.check(sht.selected());
deleting++;
}
TString msg;
msg = "Confermate l'eliminazione de";
if (deleting == 1)
@ -666,6 +668,9 @@ int TRelation_application::delete_mode()
}
}
}
else
error_box("Non e' stato selezionato nessun documento");
}
}
else
{