Patch level : 10.0

Files correlati     : agalib, lv
Ricompilazione Demo : [ ]
Commento            :
Corretta gestione tabelle di modulo.
Correzioni importanti:
Le ricerche sulle tabelle di modulo sono filtrate correttamente
La descrizione della tabella di modulo viene reperita correttamente


git-svn-id: svn://10.65.10.50/trunk@17015 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2008-08-06 10:30:33 +00:00
parent 2398a832f0
commit 0b2aaa4eb9
7 changed files with 76 additions and 43 deletions

View File

@ -510,11 +510,9 @@ public:
void zero(const char * fieldname) void zero(const char * fieldname)
{ curr().zero(fieldname);} { curr().zero(fieldname);}
// @cmember Vuota il contenuto del record corrente // @cmember Vuota il contenuto del record corrente
virtual void zero() virtual void zero() { curr().zero();}
{ curr().zero();}
// @cmember Vuota tutto il record corrente usando il carattere <p c> // @cmember Vuota tutto il record corrente usando il carattere <p c>
void zero(char c) void zero(char c) { curr().zero(c);}
{ curr().zero(c);}
// @cmember Riempie il campo <p fieldname> del record corrente di spazi // @cmember Riempie il campo <p fieldname> del record corrente di spazi
void blank(const char * fieldname) void blank(const char * fieldname)
{ curr().blank(fieldname); } { curr().blank(fieldname); }

View File

@ -2202,7 +2202,7 @@ int TBrowse::do_input(
return ne; return ne;
TRectype& cur = _cursor->curr(); TRectype& cur = _cursor->curr();
cur.zero(); _cursor->file(0).zero(); // was cur.zero() che non va bene per le tabelle di modulo
TRectype filtrec(cur); TRectype filtrec(cur);
_inp_id.restart(); _inp_id.restart();
@ -3196,10 +3196,15 @@ bool TEdit_field::parse_item(TScanner& scanner)
TDir d; d.get(logicnum); TDir d; d.get(logicnum);
if (fexist(d.filename())) // Controlla l'esistenza del file if (fexist(d.filename())) // Controlla l'esistenza del file
{ {
if (logicnum >= LF_TABGEN && logicnum <= LF_TAB) switch (logicnum)
r = new TRelation(tablename);
else
{ {
case LF_TABGEN:
case LF_TABCOM:
case LF_TAB:
case LF_TABMOD:
r = new TRelation(tablename);
break;
default:
r = new TRelation(logicnum); r = new TRelation(logicnum);
tablename.cut(0); tablename.cut(0);
} }
@ -3242,7 +3247,7 @@ bool TEdit_field::parse_item(TScanner& scanner)
} }
scanner.push(); scanner.push();
if (tablename.not_empty()) if (tablename.full())
{ {
tablename.insert("MTB", 0); tablename.insert("MTB", 0);
browse()->set_insert(tablename); browse()->set_insert(tablename);

View File

@ -51,7 +51,7 @@ bool TTable_module_application::user_create()
TString4 tabname = argv(2); TString4 tabname = argv(2);
tabname.upper(); tabname.upper();
if (tabname.len() == 3) if (tabname[0] != '&')
tabname.insert("&"); // Forza la tabella di modulo tabname.insert("&"); // Forza la tabella di modulo
_rel = new TRelation(tabname); _rel = new TRelation(tabname);
_msk = user_create_mask(); _msk = user_create_mask();

View File

@ -1073,10 +1073,18 @@ void TCursor_parser::parse_join_param(TRelation* rel, const TString& j, int to)
yesnofatal_box("JOIN senza espressioni INTO"); yesnofatal_box("JOIN senza espressioni INTO");
const int logicnum = table2logic(j); const int logicnum = table2logic(j);
if (logicnum != LF_TAB && logicnum != LF_TABCOM) switch (logicnum)
rel->add(logicnum, exp, key, to, alias); // join file {
else case LF_TABGEN:
case LF_TABCOM:
case LF_TAB:
case LF_TABMOD:
rel->add(j, exp, key, to, alias); // join table rel->add(j, exp, key, to, alias); // join table
break;
default:
rel->add(logicnum, exp, key, to, alias); // join file
break;
}
TString16 tabname; TString16 tabname;
if (alias > 0) if (alias > 0)
@ -1110,9 +1118,7 @@ void TCursor_parser::parse_sortedjoin()
const TString j = pop(); // File or table const TString j = pop(); // File or table
const TString& tok = pop(); const TString& tok = pop();
if (tok == "BY" ) if (tok == "BY" )
{
parse_sortexpr(sortexp); parse_sortexpr(sortexp);
}
else else
push(); push();

View File

@ -320,7 +320,7 @@ void TRelation::restore_status()
file(i).setkey(key); file(i).setkey(key);
if (recno >= 0l) file(i).readat(recno); if (recno >= 0l) file(i).readat(recno);
else file(i).curr().zero(); else file(i).zero();
file(i).setstatus(err); file(i).setstatus(err);
} }
_status.get(_files.items()*3 - 1); // mi riposiziono prima di tutti i first_match _status.get(_files.items()*3 - 1); // mi riposiziono prima di tutti i first_match
@ -546,7 +546,11 @@ bool TRelation::add(int logicnum, const char* relexprs, int key,
bool TRelation::add(const char* tabname, const char* relexprs, int key, bool TRelation::add(const char* tabname, const char* relexprs, int key,
int linkto, int alias, bool allow_lock) int linkto, int alias, bool allow_lock)
{ {
TTable* t = new TTable(tabname); TLocalisamfile* t = NULL;
if (*tabname == '&')
t = new TModule_table(tabname);
else
t = new TTable(tabname);
return add(t, relexprs, key, linkto, alias, allow_lock); return add(t, relexprs, key, linkto, alias, allow_lock);
} }
@ -581,8 +585,8 @@ void TRelation::replacef(
{ {
int index=0; int index=0;
if (lognum<0) index=alias2ind(lognum); if (lognum < 0) index=alias2ind(lognum);
if (lognum>0) index=log2ind(lognum); if (lognum > 0) index=log2ind(lognum);
replace(f,index,relexprs,key); replace(f,index,relexprs,key);
} }
@ -1289,7 +1293,7 @@ TRecnotype TCursor::update()
TLocalisamfile& f = file(); TLocalisamfile& f = file();
f.setkey(_nkey); f.setkey(_nkey);
if (f.curr().empty()) if (f.curr().empty())
f.curr().zero(); f.zero(); // Usare sempre l'azzeratore esperto del file non direttamente f.curr().zero()
f.read(_isgteq); f.read(_isgteq);
_totrec = buildcursor(f.recno()); _totrec = buildcursor(f.recno());
@ -1349,13 +1353,27 @@ void TCursor::filter(
{ {
TString kf(_keyfrom), kto(_keyto); TString kf(_keyfrom), kto(_keyto);
const bool filterchanged = (fil != NULL) && (_filter != fil); const bool filterchanged = (fil != NULL) && (_filter != fil);
if (file().tab()) switch (file().num())
{
case LF_TABGEN:
case LF_TABCOM:
case LF_TAB:
{ {
const TTable& f = (const TTable&)file(); const TTable& f = (const TTable&)file();
kf = kto = f.name(); kf = kto = f.name();
};
break;
case LF_TABMOD:
{
const TModule_table& t = (TModule_table&)file();
kf.format("%2s%6ld%3s", (const char*)t.module(), t.customer(), (const char*)t.name());
kto = kf;
}
break;
default:
break;
} }
if (from != NULL) if (from != NULL)
matildator(*from, _nkey, (tilde & 0x1) != 0, kf); matildator(*from, _nkey, (tilde & 0x1) != 0, kf);
@ -1587,7 +1605,7 @@ TCursor::TCursor(TRelation* r, const char* fil, int nkey,
_totrec = 0; _totrec = 0;
_lastrec = 0; _lastrec = 0;
_lastkrec = 0; _lastkrec = 0;
_pagefirstpos = 0L, _pagefirstpos = 0L;
_page = new TRecnotype[_cmaxelpage]; _page = new TRecnotype[_cmaxelpage];
memset(_page, 0, _cmaxelpage * sizeof(TRecnotype)); memset(_page, 0, _cmaxelpage * sizeof(TRecnotype));
@ -1620,7 +1638,7 @@ TRecnotype TCursor::readrec()
if (_pos >= items()) if (_pos >= items())
{ {
file().setstatus(_iseof); file().setstatus(_iseof);
curr().zero(); file().zero();
return nrec; return nrec;
} }
file().setstatus(NOERR); file().setstatus(NOERR);

View File

@ -20,13 +20,8 @@ TModule_table::TModule_table(const char* tabname, const char* module, long custo
if (_customer <= 0L && real::is_natural(appname.mid(3))) if (_customer <= 0L && real::is_natural(appname.mid(3)))
_customer = atol(app.mid(2)); _customer = atol(app.mid(2));
} }
// @cmember Vuota tutto il record usando il carattere <p c>
void TModule_table::zero(char c)
{
zero(curr(), c);
}
void TModule_table::zero(TRectype & rec, char c) void TModule_table::zero_rec(TRectype& rec, char c)
{ {
rec.zero(c); rec.zero(c);
rec.put("COD", _tabname); rec.put("COD", _tabname);
@ -34,6 +29,18 @@ void TModule_table::zero(TRectype & rec, char c)
rec.put("CUST", _customer); rec.put("CUST", _customer);
} }
// @cmember Vuota tutto il record
void TModule_table::zero()
{
zero_rec(curr(), '\0');
}
// @cmember Vuota tutto il record usando il carattere <p c>
void TModule_table::zero(char c)
{
zero_rec(curr(), c);
}
bool TModule_table::in_table() const bool TModule_table::in_table() const
{ {
const TRectype& rec = curr(); const TRectype& rec = curr();
@ -69,18 +76,18 @@ int TModule_table::_read(TRectype& rec, word op, word lockop)
{ {
case _isfirst: case _isfirst:
{ {
zero(rec); zero_rec(rec, '\0');
TBaseisamfile::_read(rec, _isgteq, lockop); TBaseisamfile::_read(rec, _isgteq, lockop);
if (not_in_table()) if (not_in_table())
setstatus(_isemptyfile); setstatus(_isemptyfile);
if (bad()) if (bad())
zero(rec); zero_rec(rec, '\0');
} }
break; break;
case _islast: case _islast:
{ {
zero(rec); zero_rec(rec, '\0');
put("CODTAB", "\xFF"); put("CODTAB", "\xFF");
TBaseisamfile::_read(rec, _isgteq); TBaseisamfile::_read(rec, _isgteq);
if (!eof()) if (!eof())
@ -92,7 +99,7 @@ int TModule_table::_read(TRectype& rec, word op, word lockop)
if (not_in_table()) if (not_in_table())
setstatus(_isemptyfile); setstatus(_isemptyfile);
if (bad()) if (bad())
zero(rec); zero_rec(rec, '\0');
} }
break; break;
case _isprev: case _isprev:
@ -188,10 +195,10 @@ void TModule_table::load_module_description()
c.format("%06ld", _customer); c.format("%06ld", _customer);
n << c; n << c;
} }
n << _tabname; n << "tb" << _tabname;
n.ext("msk"); n.ext("msk");
if (n.exist()) if (n.custom_path())
{ {
TScanner m(n); TScanner m(n);
bool ok = true; bool ok = true;

View File

@ -40,13 +40,13 @@ protected:
bool in_table() const ; bool in_table() const ;
// @cmember Testa se il record fa non parte della tabella // @cmember Testa se il record fa non parte della tabella
bool not_in_table() const { return !in_table(); } bool not_in_table() const { return !in_table(); }
// @cmember Vuota tutto il record passato usando il carattere <p c>
void zero_rec(TRectype& rec, char c);
// @access Public Member // @access Public Member
public: public:
// @cmember Salta <p nrec> record dalla posizione corrente // @cmember Salta <p nrec> record dalla posizione corrente
virtual int skip(TRecnotype nrec, word lockop = _nolock); virtual int skip(TRecnotype nrec, word lockop = _nolock);
// @cmember Controlla se si tratta di una tabella (ritorna sempre TRUE)
virtual bool tab() const { return true; }
// @cmember Ritorna il nome della tabella // @cmember Ritorna il nome della tabella
virtual const char* name() const { return _tabname;} virtual const char* name() const { return _tabname;}
// @cmember Ritorna il modulo al quale appartiene la tabella // @cmember Ritorna il modulo al quale appartiene la tabella
@ -60,11 +60,10 @@ public:
virtual bool empty(); virtual bool empty();
// @cmember Ritorna la relapp che gestisce la tabella // @cmember Ritorna la relapp che gestisce la tabella
virtual bool get_relapp(TString& app) const; virtual bool get_relapp(TString& app) const;
// @cmember Vuota tutto il record
virtual void zero();
// @cmember Vuota tutto il record usando il carattere <p c> // @cmember Vuota tutto il record usando il carattere <p c>
virtual void zero(char c = '\0'); virtual void zero(char c = '\0');
// @cmember Vuota tutto il record passato usando il carattere <p c>
void zero(TRectype & rec, char c = '\0');
// @cmember Ritorna il numero logico della tabella <p tabname> // @cmember Ritorna il numero logico della tabella <p tabname>
static int name2log(const char* tabname) { return LF_TABGEN;} static int name2log(const char* tabname) { return LF_TABGEN;}