Patch level :

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :
currency.*    Migliorata gestione valute nulle
date.h        Migliorati operatori di somma
date.cpp      Eliminato uso inutile della __tmp_date
execp.cpp     Corretta chiamata a chiusura files
expr.h        Trasformato Sandro in Alex
expr.cpp      Sostituiti vari real(0.0) con ZERO


git-svn-id: svn://10.65.10.50/trunk@7199 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1998-10-01 13:52:27 +00:00
parent 91f50e6968
commit a98e81e925
7 changed files with 46 additions and 36 deletions

View File

@ -54,7 +54,7 @@ TObject* TDowJones::rec2obj(const TRectype& rec) const
if (data->_num < 1.0) if (data->_num < 1.0)
data->_num = 1.0; data->_num = 1.0;
data->_den = rec.get_real("R10"); data->_den = rec.get_real("R10");
data->_num = 1.0;
const TString& codval = rec.get("CODTAB"); const TString& codval = rec.get("CODTAB");
data->_dec = codval.empty() || codval == "LIT" ? 0 : 2; data->_dec = codval.empty() || codval == "LIT" ? 0 : 2;
} }
@ -135,11 +135,19 @@ int TDowJones::get_dec(const char* val)
// TCurrency // TCurrency
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
void TCurrency::change_value(const char* val) void TCurrency::set_currency(const char* val)
{
if (val && *val)
strncpy(_val, val, 4);
else
strcpy(_val, DowJones.get_defval());
}
void TCurrency::change_currency(const char* val)
{ {
if (_num != ZERO) if (_num != ZERO)
_num = DowJones.exchange(_num, _val, val); _num = DowJones.exchange(_num, _val, val);
strncpy(_val, val, 4); set_currency(val);
} }
void TCurrency::read(const TRectype& rec, const char* field, const char* val) void TCurrency::read(const TRectype& rec, const char* field, const char* val)
@ -147,12 +155,10 @@ void TCurrency::read(const TRectype& rec, const char* field, const char* val)
_num = rec.get_real(field); _num = rec.get_real(field);
if (val == NULL || *val == '\0') if (val == NULL || *val == '\0')
val = "_VALUTA"; val = "_VALUTA";
TString16 tmpval;
if (rec.exist(val)) if (rec.exist(val))
strcpy(_val, rec.get(val)); tmpval = rec.get(val);
else set_currency(tmpval);
*_val = '\0';
if (*_val == '\0')
strcpy(_val, DowJones.get_defval());
} }
void TCurrency::write(TRectype& rec, const char* field, const char *val, bool forceval) const void TCurrency::write(TRectype& rec, const char* field, const char *val, bool forceval) const
@ -183,7 +189,7 @@ int TCurrency::compare(const TSortable& s) const
return _num == cur._num ? 0 : (_num > cur._num ? +1 : -1); return _num == cur._num ? 0 : (_num > cur._num ? +1 : -1);
} }
TCurrency curr(cur); TCurrency curr(cur);
curr.change_value(_val); curr.change_currency(_val);
return _num == curr._num ? 0 : (_num > curr._num ? +1 : -1); return _num == curr._num ? 0 : (_num > curr._num ? +1 : -1);
} }
@ -207,6 +213,12 @@ const char* TCurrency::string(bool dotted) const
return _num.string(picture); return _num.string(picture);
} }
TCurrency::TCurrency() : _num(0.0)
{
set_currency(NULL);
}
TCurrency::TCurrency(const TCurrency& cur) TCurrency::TCurrency(const TCurrency& cur)
: _num(cur._num) : _num(cur._num)
{ {
@ -216,6 +228,6 @@ TCurrency::TCurrency(const TCurrency& cur)
TCurrency::TCurrency(const real& num, const char* val) TCurrency::TCurrency(const real& num, const char* val)
: _num(num) : _num(num)
{ {
strncpy(_val, val, 4); set_currency(val);
} }

View File

@ -18,8 +18,9 @@ protected:
virtual int compare(const TSortable& s) const; virtual int compare(const TSortable& s) const;
public: public:
void change_value(const char* newval); void change_currency(const char* newval);
const char* get_value() const { return _val; } const char* get_currency() const { return _val; }
void set_currency(const char* newval);
void set_num(const real& num) { _num = num; } void set_num(const real& num) { _num = num; }
const real& get_num() const { return _num; } const real& get_num() const { return _num; }
@ -30,7 +31,7 @@ public:
void read(const TRectype& rec, const char* field, const char *val = NULL); void read(const TRectype& rec, const char* field, const char *val = NULL);
void write(TRectype& rec, const char* field, const char *val = NULL, bool forceval = FALSE) const; void write(TRectype& rec, const char* field, const char *val = NULL, bool forceval = FALSE) const;
TCurrency() { _val[0] = '\0'; } TCurrency();
TCurrency(const TCurrency& cur); TCurrency(const TCurrency& cur);
TCurrency(const real& num, const char* val = ""); TCurrency(const real& num, const char* val = "");
virtual ~TCurrency() { } virtual ~TCurrency() { }

View File

@ -450,7 +450,7 @@ bool TDate::ok() const
// @doc EXTERNAL // @doc EXTERNAL
// @func TDate& | operator + | Incrementa la data di un certo numero di giorni // @func TDate& | operator + | Incrementa la data di un certo numero di giorni
TDate& operator +( TDate operator +(
const TDate& a, // @parm Data a cui aggiungere i giorni const TDate& a, // @parm Data a cui aggiungere i giorni
long nday) // @parm Numero di giorni da aggiungere long nday) // @parm Numero di giorni da aggiungere
@ -458,30 +458,28 @@ TDate& operator +(
// @syntax operator + (long nday, const TDate& a) // @syntax operator + (long nday, const TDate& a)
// //
// @comm E' indifferente quale parametro viene passato per primo // @comm E' indifferente quale parametro viene passato per primo
{ {
__tmp_date = a.julian2date(a.date2julian() + nday); TDate tmp = a.julian2date(a.date2julian() + nday);
return __tmp_date; return tmp;
} }
TDate& operator +(const long nday, const TDate& b) TDate operator +(const long nday, const TDate& b)
{ {
__tmp_date = b.julian2date(b.date2julian() + nday); TDate tmp = b.julian2date(b.date2julian() + nday);
return __tmp_date; return tmp;
} }
// @doc EXTERNAL // @doc EXTERNAL
// @func TDate& | operator - | Decrementa la data di un certo numero di giorni // @func TDate& | operator - | Decrementa la data di un certo numero di giorni
TDate& operator -( TDate operator -(
const TDate& a, // @parm Data da decrementare const TDate& a, // @parm Data da decrementare
long nday) // @parm Numero di giorni da togliere long nday) // @parm Numero di giorni da togliere
{ {
__tmp_date = a.julian2date(a.date2julian() - nday); TDate tmp = a.julian2date(a.date2julian() - nday);
return __tmp_date; return tmp;
} }
// @doc EXTERNAL // @doc EXTERNAL
@ -503,9 +501,9 @@ void swap(
TDate& b) // @parm Seconda data da scambiare TDate& b) // @parm Seconda data da scambiare
{ {
__tmp_date = b; const TDate tmp = b;
b = a; b = a;
a = __tmp_date; a = tmp;
} }
// @doc EXTERNAL // @doc EXTERNAL

View File

@ -83,7 +83,7 @@ public:
int month() const ; int month() const ;
// @cmember Ritorna l'anno // @cmember Ritorna l'anno
int year() const ; int year() const ;
// @cmember Ritorna il giorno della settimana (0 = domenica) // @cmember Ritorna il giorno della settimana (1 = Lunedi, 7 = domenica)
int wday() const ; int wday() const ;
// @cmember Ritorna la settimana dell'anno // @cmember Ritorna la settimana dell'anno
int week() const ; int week() const ;
@ -194,9 +194,9 @@ public:
TFormatted_date(const TFormatted_date& d); TFormatted_date(const TFormatted_date& d);
}; };
TDate& operator +(const TDate& a, long nday) ; TDate operator +(const TDate& a, long nday) ;
TDate& operator +(const long nday, const TDate& b) ; TDate operator +(const long nday, const TDate& b) ;
TDate& operator -(const TDate& a, long nday) ; TDate operator -(const TDate& a, long nday) ;
long operator -(const TDate& a, const TDate& b) ; long operator -(const TDate& a, const TDate& b) ;
// @doc EXTERNAL // @doc EXTERNAL

View File

@ -98,7 +98,7 @@ word TExternal_app::run(
} }
*/ */
if (!async) if (!async)
prefix().close_closeable_isamfiles(); safely_close_closeable_isamfiles();
if (dongle().local()) if (dongle().local())
dongle().logout(); dongle().logout();

View File

@ -189,7 +189,7 @@ TExpression::TExpression(const char* expression, TTypeexp type, bool ignore_err)
{ {
_ignore_error=ignore_err; _ignore_error=ignore_err;
_error=0; _error=0;
_val = real(0.0); _val = ZERO;
_dirty = TRUE; _dirty = TRUE;
_type = type; _type = type;
if (!compile(_original, type)) if (!compile(_original, type))
@ -206,7 +206,7 @@ TExpression::TExpression(TTypeexp type, bool ignore_err)
{ {
_ignore_error=ignore_err; _ignore_error=ignore_err;
_error=0; _error=0;
_val = real(0.0); _val = ZERO;
_dirty = FALSE; _dirty = FALSE;
_type = type; _type = type;
_code.clear(); _code.clear();
@ -1155,13 +1155,12 @@ bool TExpression::set(const char* expression, TTypeexp type)
} }
bool TExpression::compile(const char* expression, TTypeexp type) bool TExpression::compile(const char* expression, TTypeexp type)
{ {
_error=0; _error=0;
_user_func_defined = FALSE; _user_func_defined = FALSE;
_s = expression; _s = expression;
_type = type; _type = type;
_val = real(0.0); _val = ZERO;
_code.clear(); _code.clear();
if (*_s == '\0') if (*_s == '\0')
return TRUE; return TRUE;

View File

@ -206,7 +206,7 @@ public:
// @base public | TArray // @base public | TArray
class TCodearray : public TArray class TCodearray : public TArray
// @author:(INTERNAL) Sandro // @author:(INTERNAL) Alex
// @access:(INTERNAL) Private Member // @access:(INTERNAL) Private Member
{ {