real.cpp Sostituita bisciolina residua col cappello di Pinocchio:

in altri termini ~ --> ^
recarray.cpp  Corretto metodo TFile_cache::fill nel caso delle tabelle
relapp.cpp    Migliorata gestione get_next_key
relapp.h      Aggiunta macro TRANSACTION_RUN
tokens.h      Aggiunto token CURRENCY
xvtility      Aggiunto HIDDEN alla funzione xvt_error_hook


git-svn-id: svn://10.65.10.50/trunk@6654 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1998-05-13 15:12:27 +00:00
parent d5db644881
commit 83a616f99a
6 changed files with 44 additions and 26 deletions

View File

@ -1188,6 +1188,7 @@ char *real::eng2ita (char *s)
return s; return s;
} }
// Elimina gli spazi ed i punti, converte le virgole in punti
char *real::ita2eng (const char *s) char *real::ita2eng (const char *s)
{ {
int j = 0; int j = 0;
@ -1241,8 +1242,8 @@ bool real::is_natural (const char *s)
s++; s++;
ok = *s == '\0'; ok = *s == '\0';
} }
else ok = FALSE; else
ok = FALSE;
} }
return ok; return ok;
} }
@ -1399,7 +1400,7 @@ HIDDEN int get_picture_decimals (const TString& picture, char& decsep)
{ {
const int len = picture.len (); const int len = picture.len ();
for (int i = virgola + 1; i < len; i++) for (int i = virgola + 1; i < len; i++)
if (strchr ("#@~", picture[i])) if (strchr ("#@^", picture[i]))
decimali++; decimali++;
} }
return decimali; return decimali;
@ -1411,7 +1412,7 @@ char* real::string(const char *picture) const
return string (); return string ();
if (*picture == '.') if (*picture == '.')
return points (atoi (picture + 1)); return points (atoi (picture + 1));
if (strcmp (picture, "LETTERE") == 0) if (stricmp (picture, "LETTERE") == 0)
return literals (); return literals ();
TString v (string()); TString v (string());
@ -1423,9 +1424,12 @@ char* real::string(const char *picture) const
f.rtrim(1); f.rtrim(1);
decsep = '.'; decsep = '.';
} }
// Calcola il numero di decimali voluti ed eventualmente
// determina il vero separatore dei decimali
const int voluti = get_picture_decimals (f, decsep);
const char migsep = decsep == '.' ? ',' : '.'; // Separatore delle migliaia const char migsep = decsep == '.' ? ',' : '.'; // Separatore delle migliaia
const int voluti = get_picture_decimals (f, decsep);
const int virgola = v.find ('.'); // v e' la nostra cifra, certamente in english format const int virgola = v.find ('.'); // v e' la nostra cifra, certamente in english format
int decimali = (virgola >= 0) ? v.len () - virgola - 1 : 0; int decimali = (virgola >= 0) ? v.len () - virgola - 1 : 0;

View File

@ -407,13 +407,13 @@ TFile_cache::TFile_cache(TLocalisamfile *f , int key)
} }
TFile_cache::TFile_cache(int num, int key) TFile_cache::TFile_cache(int num, int key)
: _file(NULL), _key(key) : _file(NULL), _key(key), _last_firm(-883)
{ {
_code << num; _code << num;
} }
TFile_cache::TFile_cache(const char* tab, int key) TFile_cache::TFile_cache(const char* tab, int key)
: _file(NULL), _key(key) : _file(NULL), _key(key), _last_firm(-883)
{ {
_code = tab; _code = tab;
} }
@ -426,9 +426,10 @@ TFile_cache::~TFile_cache()
void TFile_cache::init_file(TLocalisamfile* f) void TFile_cache::init_file(TLocalisamfile* f)
{ {
CHECK(_file == NULL, "File already initialized"); if (_file != NULL)
delete _file;
if (f==NULL) if (f == NULL)
{ {
int logicnum = atoi(_code); int logicnum = atoi(_code);
if (logicnum == 0) if (logicnum == 0)
@ -444,15 +445,18 @@ void TFile_cache::init_file(TLocalisamfile* f)
else else
_file = f; _file = f;
TDir dir; if (_file != NULL)
dir.get(_file->num()); {
// Se e' un file comune metti a -1, altrimenti alla ditta corrente TDir dir;
_last_firm = dir.is_com() ? -1 : prefix().get_codditta(); dir.get(_file->num());
// Se e' un file comune metti a -1, altrimenti alla ditta corrente
_last_firm = dir.is_com() ? -1 : prefix().get_codditta();
}
} }
void TFile_cache::test_firm() void TFile_cache::test_firm()
{ {
if (_file == NULL) if (_last_firm < -1)
init_file(); init_file();
if (_last_firm >= 0) // Se e' un file di ditta ... if (_last_firm >= 0) // Se e' un file di ditta ...
@ -472,15 +476,17 @@ const TObject& TFile_cache::query(const char* code)
_error = NOERR; _error = NOERR;
_code = code; _code = code;
TObject* obj = _cache.objptr(_code); TObject* obj = _cache.objptr(_code);
if (obj == NULL) if (obj == NULL)
{ {
TRectype& curr = _file->curr(); TLocalisamfile& f = file();
TRectype& curr = f.curr();
if (_code.not_empty()) if (_code.not_empty())
{ {
const RecDes* recd = curr.rec_des(); // Descrizione del record della testata const RecDes* recd = curr.rec_des(); // Descrizione del record della testata
const KeyDes& kd = recd->Ky[_key-1]; // Elenco dei campi della chiave const KeyDes& kd = recd->Ky[_key-1]; // Elenco dei campi della chiave
for (int i = _file->tab() ? 1 :0; i < kd.NkFields; i++) // Riempie la chiave selezionata for (int i = f.tab() ? 1 :0; i < kd.NkFields; i++) // Riempie la chiave selezionata
{ {
const int nf = kd.FieldSeq[i] % MaxFields; const int nf = kd.FieldSeq[i] % MaxFields;
const RecFieldDes& rf = recd->Fd[nf]; const RecFieldDes& rf = recd->Fd[nf];
@ -490,8 +496,8 @@ const TObject& TFile_cache::query(const char* code)
else else
NFCHECK("Valore del campo chiave %s non specificato per la cache", rf.Name); NFCHECK("Valore del campo chiave %s non specificato per la cache", rf.Name);
} }
_file->setkey(_key); f.setkey(_key);
_error = _file->read(); _error = f.read();
} else } else
_error = _iskeyerr; _error = _iskeyerr;
switch (_error) switch (_error)
@ -503,6 +509,7 @@ const TObject& TFile_cache::query(const char* code)
case _isemptyfile: case _isemptyfile:
default: default:
curr.zero(); curr.zero();
break;
} }
obj = rec2obj(curr); obj = rec2obj(curr);
_cache.add(_code, obj); _cache.add(_code, obj);
@ -519,16 +526,17 @@ int TFile_cache::io_result()
int TFile_cache::fill() int TFile_cache::fill()
{ {
test_firm(); test_firm();
_file->setkey(_key);
TRectype& curr = _file->curr(); TLocalisamfile& f = file();
TRectype& curr = f.curr();
const RecDes* recd = curr.rec_des(); // Descrizione del record della testata const RecDes* recd = curr.rec_des(); // Descrizione del record della testata
const KeyDes& kd = recd->Ky[_key-1]; // Elenco dei campi della chiave const KeyDes& kd = recd->Ky[_key-1]; // Elenco dei campi della chiave
for (int err = _file->first(); err == NOERR; err = _file->next()) for (int err = f.first(); err == NOERR; err = f.next())
{ {
_code.cut(0); _code.cut(0);
for (int i = 0; i < kd.NkFields; i++) // Riempie la chiave selezionata for (int i = f.tab() ? 1 :0; i < kd.NkFields; i++) // Riempie la chiave selezionata
{ {
const int nf = kd.FieldSeq[i] % MaxFields; const int nf = kd.FieldSeq[i] % MaxFields;
const RecFieldDes& rf = recd->Fd[nf]; const RecFieldDes& rf = recd->Fd[nf];
@ -539,12 +547,15 @@ int TFile_cache::fill()
_cache.add(_code, obj); _cache.add(_code, obj);
} }
// Non serve piu'
delete _file; _file = NULL;
return _cache.items(); return _cache.items();
} }
TLocalisamfile & TFile_cache::file() TLocalisamfile& TFile_cache::file()
{ {
if (!_file) if (_file == NULL)
init_file(); init_file();
return *_file; return *_file;
} }

View File

@ -251,8 +251,9 @@ bool TRelation_application::autonum(
TToken_string k; TToken_string k;
if (!get_next_key(k)) if (!get_next_key(k))
{ {
NFCHECK("La 'const char* get_next_key()' verra' sostituita dalla 'bool get_next_key(TToken_string&)'");
k = get_next_key(); k = get_next_key();
if (k.not_empty())
NFCHECK("La 'const char* get_next_key()' verra' sostituita dalla 'bool get_next_key(TToken_string&)'");
} }
if (!rec && !m->query_mode()) if (!rec && !m->query_mode())

View File

@ -20,6 +20,7 @@
#define TRANSACTION_INSERT "INSERT" #define TRANSACTION_INSERT "INSERT"
#define TRANSACTION_MODIFY "MODIFY" #define TRANSACTION_MODIFY "MODIFY"
#define TRANSACTION_DELETE "DELETE" #define TRANSACTION_DELETE "DELETE"
#define TRANSACTION_RUN "RUN"
#define TM_INTERACTIVE 'I' #define TM_INTERACTIVE 'I'
#define TM_AUTOMATIC 'A' #define TM_AUTOMATIC 'A'
// @doc EXTERNAL // @doc EXTERNAL

View File

@ -11,6 +11,7 @@
#define COPY CO #define COPY CO
#define DATE DA #define DATE DA
#define DISPLAY DI #define DISPLAY DI
#define DRIVENBY DR
#define EMPTY 0 #define EMPTY 0
#define END EN #define END EN
#define ENDPAGE EN #define ENDPAGE EN

View File

@ -21,7 +21,7 @@ void ignore_xvt_errors(bool ixe)
_ignore_xvt_errors = ixe; _ignore_xvt_errors = ixe;
} }
BOOLEAN error_hook(XVT_ERRMSG err, DATA_PTR) HIDDEN BOOLEAN error_hook(XVT_ERRMSG err, DATA_PTR)
{ {
if (_ignore_xvt_errors) if (_ignore_xvt_errors)
return TRUE; return TRUE;