Modifiche per collegare una tabella in base al modulo al
quale appartiene. ISAM.H, ISAM.CPP : modificato metodo TBaseisamfile::description() MASKFLD.CPP : modifica alla gestione della chiamata al programma di gestione in base al modulo della tabella PREFIX.CPP : " " " TABAPP.CPP : modifiche per lettura nome file tabella TABUTIl.H TABUTIL.CPP : aggiunti metodi per leggere modulo e descrizione della tabella. git-svn-id: svn://10.65.10.50/trunk@5110 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
3eee098124
commit
3e54971b14
@ -821,7 +821,7 @@ const char* TBaseisamfile::filename() const
|
||||
return _isam_string;
|
||||
}
|
||||
|
||||
const char* TBaseisamfile::description() const
|
||||
const char* TBaseisamfile::description()
|
||||
{
|
||||
if (_isamfile == NULL && num() < EXTERNAL_FILE)
|
||||
{
|
||||
|
@ -444,7 +444,7 @@ public:
|
||||
int num() const
|
||||
{ return _logicnum;}
|
||||
// @cmember Ritorna la descrizione del file corrente
|
||||
const char* description() const;
|
||||
virtual const char* description();
|
||||
// @cmember Ritorna il numero di record contenuti nel file corrente
|
||||
virtual TRecnotype eod() const ;
|
||||
|
||||
|
@ -2159,9 +2159,22 @@ bool TBrowse::do_link(bool insert)
|
||||
if (_insert[0] == 'M')
|
||||
{
|
||||
TString nm(_insert.mid(1));
|
||||
if (nm.compare("batb", 4, TRUE) == 0) // Programma gestione tabelle
|
||||
app = format("ba3 -0 %s", (const char*)nm.mid(4));
|
||||
// if (nm.compare("batb", 4, TRUE) == 0) // Programma gestione tabelle
|
||||
if (nm.compare("tb", 2, TRUE) == 0) // Programma gestione tabelle
|
||||
{
|
||||
// app = format("ba3 -0 %s", (const char*)nm.mid(4));
|
||||
const char* module = ((TTable&)_cursor->file()).module();
|
||||
TString prg("ba3 -0");
|
||||
if (strcmp(module,"ba")!=0)
|
||||
{
|
||||
TConfig c(CONFIG_STUDIO);
|
||||
prg = c.get("TabPrg",module);
|
||||
if (prg.empty())
|
||||
prg = "ba3 -0";
|
||||
}
|
||||
app = format("%s %s", (const char*)prg,(const char*)nm.mid(2));
|
||||
// Obbligatorio usare la format globale
|
||||
}
|
||||
else // Programma generico di browse/edit
|
||||
app = format("ba3 -3 %s %d", (const char*)nm, _cursor->file().num());
|
||||
// Obbligatorio usare la format globale
|
||||
@ -2320,8 +2333,9 @@ KEY TBrowse::run()
|
||||
do_input(TRUE);
|
||||
_cursor->read(_isgteq);
|
||||
|
||||
const TLocalisamfile& f = _cursor->file();
|
||||
TString caption(prefix().description(f.name()));
|
||||
//const TLocalisamfile& f = _cursor->file();
|
||||
//TString caption(prefix().description(f.name()));
|
||||
TString caption(_cursor->file().description());
|
||||
if (!isalnum(caption[0]))
|
||||
caption = "Selezione";
|
||||
|
||||
@ -2661,7 +2675,8 @@ bool TEdit_field::parse_item(TScanner& scanner)
|
||||
|
||||
if (tabmaskname.not_empty())
|
||||
{
|
||||
tabmaskname.insert("MBATB", 0);
|
||||
// tabmaskname.insert("MBATB", 0);
|
||||
tabmaskname.insert("MTB", 0);
|
||||
browse()->set_insert(tabmaskname);
|
||||
}
|
||||
_check_enabled = TRUE;
|
||||
|
@ -10,7 +10,7 @@
|
||||
#endif
|
||||
|
||||
#include <extcdecl.h>
|
||||
#include <isam.h>
|
||||
#include <tabutil.h>
|
||||
#include <scanner.h>
|
||||
#include <utility.h>
|
||||
|
||||
@ -369,35 +369,14 @@ const char* TPrefix::description(
|
||||
const int logicnum = atoi(n);
|
||||
if (logicnum == 0)
|
||||
{
|
||||
TFilename name("batb");
|
||||
name << n << ".msk";
|
||||
if (fexist(name.lower()))
|
||||
{
|
||||
TScanner m(name);
|
||||
bool ok = TRUE;
|
||||
while (ok)
|
||||
{
|
||||
const TString& l2 = m.line().left(2);
|
||||
if (l2.empty())
|
||||
ok = FALSE;
|
||||
else
|
||||
if (l2 == "PA")
|
||||
break;
|
||||
}
|
||||
if (ok)
|
||||
{
|
||||
const int apicia = m.token().find('"')+1;
|
||||
const int apicic = m.token().find('"', apicia);
|
||||
n = m.token().sub(apicia, apicic);
|
||||
}
|
||||
}
|
||||
else n.cut(0);
|
||||
TTable t(cod);
|
||||
n = t.description();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (logicnum > 0 && logicnum < items())
|
||||
{
|
||||
const TBaseisamfile f(logicnum);
|
||||
TBaseisamfile f(logicnum);
|
||||
n = f.description();
|
||||
}
|
||||
else n.cut(0);
|
||||
|
@ -59,12 +59,16 @@ bool Tab_application::protected_record(TRectype& rec)
|
||||
|
||||
TString& Tab_application::get_mask_name(TString& t) const
|
||||
{
|
||||
CHECK(_rel,"Can't use a NULL relation to retrieve table module");
|
||||
t = _tabname;
|
||||
if (t[0] == '%')
|
||||
t.ltrim(1);
|
||||
t.insert("batb", 0);
|
||||
t.upper();
|
||||
return t;
|
||||
TTable& tab = (TTable&) _rel->lfile(_tabname);
|
||||
|
||||
if (t[0] == '%') t.ltrim(1);
|
||||
TString16 m;
|
||||
m << tab.module();
|
||||
m << "tb" << t;
|
||||
t = m;
|
||||
return m.upper();
|
||||
}
|
||||
|
||||
TMask* Tab_application::set_mask(TMask* m)
|
||||
|
@ -3,6 +3,7 @@
|
||||
#define __TABUTIL_CPP
|
||||
#include <tabutil.h>
|
||||
#include <extcdecl.h>
|
||||
#include <scanner.h>
|
||||
#include <utility.h>
|
||||
|
||||
int TTable::name2log(const char* n)
|
||||
@ -18,6 +19,7 @@ TTable::TTable(const char* tabname, bool linkrecinst)
|
||||
_tabname = tabname;
|
||||
_tabname.upper();
|
||||
curr().settab(_tabname);
|
||||
_des_mod_loaded = FALSE;
|
||||
}
|
||||
|
||||
TTable::~TTable()
|
||||
@ -181,4 +183,76 @@ int TTable::readat(TRectype& rec ,TRecnotype nrec, word lockop)
|
||||
return status();
|
||||
}
|
||||
|
||||
void TTable::load_module_description()
|
||||
{
|
||||
// Setta il modulo al quale appartiene la tabella e la relativa descrizione.
|
||||
// Cerca prima in RECDESC il relativo file di descrizione: D<TAB_NAME>.DES
|
||||
// Se il file esiste, se il paragrafo [TabDescr] esiste e se esiste la
|
||||
// variabile Module ne prende il valore.
|
||||
// Se non si verificano le suddette condizioni procede come segue:
|
||||
// cerca se esiste il file ??<TAB_NAME>.MSK tramite la funzione list_files(),
|
||||
// ne estrae il module dai primi 2 caratteri e la descrizione dalla intestazione
|
||||
// della prima pagina.
|
||||
_des_mod_loaded = TRUE;
|
||||
TFilename n;
|
||||
n << "recdesc/d" << _tabname;
|
||||
n.ext("des");
|
||||
n.lower();
|
||||
if (fexist(n))
|
||||
{
|
||||
TConfig des(n);
|
||||
_module = des.get("Module","TabDescr");
|
||||
}
|
||||
n = "??tb";
|
||||
n << _tabname;
|
||||
n.ext("msk");
|
||||
n.lower();
|
||||
TToken_string f;
|
||||
f.add(n);
|
||||
if (list_files(f) == 1)
|
||||
{
|
||||
n = f.get(0);
|
||||
if (!fexist(n))
|
||||
n.overwrite("ba",0);
|
||||
if (fexist(n))
|
||||
{
|
||||
if (_module.empty())
|
||||
_module = n.left(2);
|
||||
TScanner m(n);
|
||||
bool ok = TRUE;
|
||||
while (ok)
|
||||
{
|
||||
const TString& l2 = m.line().left(2);
|
||||
if (l2.empty())
|
||||
ok = FALSE;
|
||||
else
|
||||
if (l2 == "PA")
|
||||
break;
|
||||
}
|
||||
if (ok)
|
||||
{
|
||||
const int apicia = m.token().find('"')+1;
|
||||
const int apicic = m.token().find('"', apicia);
|
||||
_description = m.token().sub(apicia, apicic);
|
||||
}
|
||||
}
|
||||
else
|
||||
_module = "ba";
|
||||
}
|
||||
else
|
||||
_module = "ba";
|
||||
}
|
||||
|
||||
const char* TTable::module()
|
||||
{
|
||||
if (!_des_mod_loaded)
|
||||
load_module_description();
|
||||
return _module;
|
||||
}
|
||||
|
||||
const char* TTable::description()
|
||||
{
|
||||
if (!_des_mod_loaded)
|
||||
load_module_description();
|
||||
return _description;
|
||||
}
|
||||
|
@ -18,9 +18,18 @@ class TTable : public TLocalisamfile
|
||||
{
|
||||
// @cmember:(INTERNAL) Nome della tabella
|
||||
TString16 _tabname;
|
||||
// @cmember:(INTERNAL) Modulo della tabella
|
||||
TString16 _module;
|
||||
// @cmember:(INTERNAL) Descrizione della tabella
|
||||
TString _description;
|
||||
// @cmember:(INTERNAL) Codice della tabella
|
||||
TRecfield _cod;
|
||||
// @cmember:(INTERNAL) Flag che indica l'avvenuto caricamento di descrizione e modulo
|
||||
bool _des_mod_loaded;
|
||||
|
||||
// @access Protected Member
|
||||
protected:
|
||||
void load_module_description();
|
||||
// @access Public Member
|
||||
public:
|
||||
// @cmember Si posiziona sul primo record della tabella
|
||||
@ -47,7 +56,10 @@ public:
|
||||
// @cmember Ritorna il nome della tabella
|
||||
virtual const char* name() const
|
||||
{ return _tabname;}
|
||||
|
||||
// @cmember Ritorna il modulo al quale appartiene la tabella
|
||||
const char* module();
|
||||
// @cmember Ritorna la descrizione della tabella
|
||||
virtual const char* description();
|
||||
// @cmember Costruttore
|
||||
TTable(const char* tabname, bool linkrecinst = FALSE);
|
||||
// @cmember Distruttore
|
||||
|
Loading…
x
Reference in New Issue
Block a user