diff --git a/include/isam.cpp b/include/isam.cpp index dbcfff327..8b113dc07 100755 --- a/include/isam.cpp +++ b/include/isam.cpp @@ -928,9 +928,10 @@ int TBaseisamfile::reread(TRectype& rec, word lockop) int TBaseisamfile::skip(TRecnotype nrec, word lockop) { - if (!nrec) return NOERR; + if (nrec == 0) + return NOERR; + curr().setdirty(); - const int fhnd = handle(); // controllo se mi sono spostato dall'ultima lettura diff --git a/include/lffiles.h b/include/lffiles.h index ceb2d8a37..424f3fdda 100755 --- a/include/lffiles.h +++ b/include/lffiles.h @@ -134,7 +134,6 @@ #define LF_COLLDICH 127 #define LF_IDONEITA 128 - #define LF_ATSTATS 129 #define LF_ATOPERA 130 #define LF_ATROPERA 131 @@ -162,20 +161,23 @@ #define LF_RRIP 150 #define LF_SALDANA 151 -#define LF_RILPROD 152 -#define LF_RRILPROD 153 +#define LF_RILPROD 152 +#define LF_RRILPROD 153 #define LF_LETINT 154 #define LF_PANAPDC 155 #define LF_MULTIREL 156 -#define LF_TURNI 157 -#define LF_RIGHEF24 158 +#define LF_TURNI 157 +#define LF_RIGHEF24 158 #define LF_RICLPDC 159 + +// Magari spostare in TABMOD in futuro #define LF_MERCATICOOP 160 #define LF_SOCICOOP 161 #define LF_IMBARCAZIONI 162 +#define LF_TABMOD 163 #define LF_EXTERNAL 1000 // Files with id >= are considered to be externals diff --git a/include/modtbapp.cpp b/include/modtbapp.cpp index a5fe541ab..d3035c365 100755 --- a/include/modtbapp.cpp +++ b/include/modtbapp.cpp @@ -1,30 +1,16 @@ #include -#include -#include - -// @cmember Costruttore -TTable_module_application::TTable_module_application() - : _msk(NULL), _rel(NULL) -{ } - -// @cmember Distruttore -TTable_module_application::~TTable_module_application() -{ } - -// @cmember Indica se la futura ritornera' una maschera diversa -// dalla corrente. -bool TTable_module_application::changing_mask(int mode) -{ return FALSE; } +#include +#include // @cmember Richiede la maschera da usare -TMask* TTable_module_application::get_mask(int mode) -{ +TMask* TTable_module_application::get_mask(int) +{ CHECK(_msk, "Null mask"); return _msk; } // @cmember Ritorna la relazione da modificare -TRelation* TTable_module_application::get_relation() const +TRelation* TTable_module_application::get_relation() const { CHECK(_rel, "Null relation"); return _rel; @@ -32,71 +18,30 @@ TRelation* TTable_module_application::get_relation() const void TTable_module_application::print() { + const TModule_table& tab = (const TModule_table&)file(); TString16 cmd; - cmd << "ba3 -1 " << get_tabname(); + cmd << tab.module() << "1 -0 " << tab.name(); TExternal_app stampa(cmd); stampa.run(); } -void TTable_module_application::init_query_mode(TMask& m) -{ - m.enable(-GR_MODIFY_PROTECTED); - m.enable(-GR_RECORD_PROTECTED); -} - -void TTable_module_application::init_modify_mode(TMask& m) -{ - m.disable(-GR_MODIFY_PROTECTED); - const bool enable = !(_rel->curr().get_bool(FPC)); - m.enable(-GR_RECORD_PROTECTED,enable); -} - bool TTable_module_application::protected_record(TRectype& rec) { - return rec.get_bool(FPC); + return rec.get_bool("FPC"); } -TString& TTable_module_application::get_mask_name(TString& t) const +TMask* TTable_module_application::user_create_mask() { - CHECK(_rel,"Can't use a NULL relation to retrieve table module"); - TTable& tab = (TTable&) _rel->lfile(); - - TString16 m = _tabname; - if (m[0] == '%') m.ltrim(1); - - t = tab.module(); - t << "tb" << m; - t.lower(); - - TFilename n(t); n.ext("msk"); - if (!n.custom_path()) - t.overwrite("ba"); - return t; -} - -TMask* TTable_module_application::set_mask(TMask* m) -{ - if (_msk != NULL) + TModule_table& tab = (TModule_table&)file(); + TString16 name = tab.module(); + if (tab.customer() > 0) { - delete _msk; - _msk = NULL; + TString8 c; + c.format("%06ld", tab.customer()); + name << c; } - - if (m != NULL) - { - // imposta la maschera come maschera della applicazione - _msk = m; - } - else - { - // alloca la maschera standard come maschera della applicazione - TFilename name; get_mask_name(name); name.ext("msk"); - if (name.custom_path()) - _msk = new TMask(name); - else - error_box(FR("Impossibile trovare la maschera %s"), (const char*)name); - } - return _msk; + name << "tb" << tab.name(); + return new TMask(name); } bool TTable_module_application::user_create() @@ -104,224 +49,30 @@ bool TTable_module_application::user_create() if (argc() < 3) return false; - _tabname = argv(2); - _tabname.upper(); - _rel = new TRelation(_tabname); - - if (set_mask() == NULL) - return false; - - const int campi = _msk->fields(); - for (int i = 0; i < campi; i++) - { - const TMask_field& f = _msk->fld(i); - if (f.in_group(GR_SEARCH)) - { - set_search_field(f.dlg()); - break; - } - } - - TFilename rpt; get_mask_name(rpt); rpt.ext("rpt"); - if (rpt.custom_path()) - enable_menu_item(M_FILE_PRINT); - - TString title; - _msk->get_caption(title); - set_title(title); - return TRUE; -} - -bool TTable_module_application::user_destroy() -{ - if (_msk) delete _msk; - if (_rel) delete _rel; - - return TRUE; -} - -/////////////////////////////////////////////////// -// Tabelle Multirel -/////////////////////////////////////////////////// - -// @cmember Indica se la futura ritornera' una maschera diversa -// dalla corrente. -bool TMultirel_application::changing_mask(int mode) -{ return false; } - -// @cmember Richiede la maschera da usare -TMask* TMultirel_application::get_mask(int mode) -{ - CHECK(_msk, "Null mask"); - return _msk; -} - -// @cmember Ritorna la relazione da modificare -TRelation* TMultirel_application::get_relation() const -{ - CHECK(_rel, "Null relation"); - return _rel; -} - -void TMultirel_application::print() -{ - TString16 tabname; - get_mask_name(tabname); - TString cmd; - cmd << "ba8 -4 "<< tabname; - TExternal_app stampa(cmd); - stampa.run(); -} - -void TMultirel_application::get_mask_name(TString& tabname) const -{ - tabname = name().left(4); - tabname << _tabname; -} - -bool TMultirel_application::find(word k) -{ - bool ok = TRelation_application::find(k); - - if (!ok && k < 2) - { - file().setkey(1); - file().zero(); - for (TEditable_field* e = get_mask()->get_key_field(1, true); e; e = get_mask()->get_key_field(1, false)) - { - if (e->shown() || e->ghost()) // Ignora campi invisibili non ghost - e->autosave(*get_relation()); - } - - TRectype rec(file().curr()); - ok = file().read(_isequal) == NOERR; - } - - return ok; -} - -void TMultirel_application::init_insert_mode(TMask& m) -{ - TLocalisamfile multi(LF_MULTIREL); - - file().curr().zero(); - for (TEditable_field* e = get_mask()->get_key_field(1, true); e; e = get_mask()->get_key_field(1, false)) - { - if ((!e->in_group(1)) && (e->shown() || e->ghost())) - e->autosave(*get_relation()); - } - - multi.curr() = file().curr(); - if (multi.read(_isgteq) == NOERR && multi.curr() == file().curr()) - set_descr(m, multi.get("DATA")); - for (int i = m.fields() - 1; i >= 0; i--) - { - TMask_field& c = m.fld(i); - - if (c.in_group(1)) - { - c.enable(); - if (c.is_edit()) - { - TEdit_field& e = (TEdit_field&)c; - - if (e.browse() != NULL) - e.enable_check(); - } - } - } -} - -void TMultirel_application::init_modify_mode(TMask& m) -{ - for (int i = m.fields() - 1; i >= 0; i--) - { - TMask_field& c = m.fld(i); - - if (c.in_group(1)) - { - c.enable(); - _second = c.get(); - if (c.is_edit()) - { - TEdit_field& e = (TEdit_field&)c; - - if (e.browse() != NULL) - e.enable_check(); - } - } - } -} - -int TMultirel_application::rewrite(const TMask& m) -{ - int err = TRelation_application::rewrite(m); - - if (err != NOERR) - err = TRelation_application::write(m); - - TRelation & rel = *get_relation(); - const TString & second = rel.lfile().get("SECOND"); - - if (err == NOERR && second != _second) - { - - rel.save_status(); - rel.lfile().put("SECOND", _second); - rel.remove(); - rel.restore_status(); - } - return err; -} - -bool TMultirel_application::user_create() -{ - if (argc() < 3) - return false; - - _tabname = argv(2); - _tabname.upper(); - _rel = new TRelation(LF_MULTIREL); - - //costruisce il nome della maschera interessata - //nome modulo + 'ts' + nome tabella - TString16 tabname; - get_mask_name(tabname); - _msk = new TMask(tabname); - - FOR_EACH_MASK_FIELD((*_msk), i, f) - { - if (f->in_key(1) && !f->in_group(1)) - { - set_search_field(f->dlg()); - break; - } - } - - TFilename rep = tabname; - rep.ext("rep"); + TString4 tabname = argv(2); + tabname.upper(); + if (tabname.len() == 3) + tabname.insert("&"); // Forza la tabella di modulo + _rel = new TRelation(tabname); + _msk = user_create_mask(); + + TFilename rep = _msk->source_file().name(); + const int tb = rep.find("tb"); + if (tb > 0) + rep.overwrite("st", tb); if (rep.custom_path()) enable_menu_item(M_FILE_PRINT); TString title; _msk->get_caption(title); set_title(title); + return true; } -bool TMultirel_application::user_destroy() +bool TTable_module_application::user_destroy() { if (_msk) delete _msk; if (_rel) delete _rel; - return true; } - -// @cmember Costruttore -TMultirel_application::TMultirel_application() - : _msk(NULL), _rel(NULL) -{ } - -// @cmember Distruttore -TMultirel_application::~TMultirel_application() -{ } diff --git a/include/modtbapp.h b/include/modtbapp.h index d6435a0de..8da5020f4 100755 --- a/include/modtbapp.h +++ b/include/modtbapp.h @@ -4,11 +4,6 @@ #ifndef __RELAPP_H #include #endif -#ifndef __DEFTABAP_H -#include -#endif - -#define FPC "FPC" // @doc EXTERNAL @@ -24,106 +19,23 @@ class TTable_module_application : public TRelation_application TMask* _msk; // @cmember:(INTERNAL) Relazione corrente dell'applicazione TRelation* _rel; - // @cmember:(INTERNAL) Nome della tabella da utilizzare - TString _tabname; // @access Protected Member protected: - // @cmember Richiede se il record corrente e' protetto (non cancellabile) + virtual bool user_create(); + virtual bool user_destroy(); virtual bool protected_record(TRectype& rec); - // @cmember Richiede la maschera da usare - virtual TMask* get_mask(int mode = MODE_QUERY); - // @cmember Indica se la futura ritornera' una maschera diversa - // dalla corrente. - virtual bool changing_mask(int mode); - // @cmember Ritorna la relazione da modificare + virtual TMask* get_mask(int mode); virtual TRelation* get_relation() const; - // @cmember Inizializza la maschera per il modo ricerca - virtual void init_query_mode(TMask& m); - // @cmember Inizializza la maschera per il modo modifica - virtual void init_modify_mode(TMask& m); - // @cmember Inizializzazione dei dati dell'utente - virtual bool user_create() ; - // @cmember Distruzione dei dati dell'utente - virtual bool user_destroy() ; - // @cmember Chiama il programma di stampa virtual void print(); - // Nuovi membri: - // @cmember Ritorna il nome della maschera associata - virtual TString& get_mask_name(TString& name) const; - // @cmember imposta la maschera (se non indicata, usa le convenzioni di default) ed eventualmente disalloca quella usata in precedenza - virtual TMask* set_mask(TMask* mask = NULL); -// @access Public Member -public: - // @cmember Ritorna il nome della tabella - const TString& get_tabname() const - { return _tabname; } - - // @cmember Costruttore - TTable_module_application(); - // @cmember Distruttore - virtual ~TTable_module_application(); -}; - -/////////////////////////////////////////////////////////////// -// Tabelle multirel -/////////////////////////////////////////////////////////////// -// @class TMultirel_application | Classe per la definizione della per le tabelle -// -// @base public | TRelation_application -class TMultirel_application : public TRelation_application - -// @author:(INTERNAL) Vari -// @access:(INTERNAL) Private Member -{ - // @cmember:(INTERNAL) Maschera corrente dell'applicazione - TMask* _msk; - // @cmember:(INTERNAL) Relazione corrente dell'applicazione - TRelation* _rel; - // @cmember:(INTERNAL) Nome della tabella da utilizzare - TString _tabname; - // @cmember:(INTERNAL) valore iniziale campo collegato - TString _second; - -// @access Protected Member protected: - - virtual void get_mask_name(TString& tabname) const; - // @cmember Richiede la maschera da usare - virtual TMask* get_mask(int mode = MODE_QUERY); - // @cmember Indica se la futura ritornera' una maschera diversa - // dalla corrente. - virtual bool changing_mask(int mode); - // @cmember Ritorna la relazione da modificare - virtual TRelation* get_relation() const; - // @cmember Inizializza la maschera per il modo inserimento - virtual void init_insert_mode(TMask& m); - // @cmember Inizializza la maschera per il modo modifica - virtual void init_modify_mode(TMask& m); - // @cmember Inizializzazione dei dati dell'utente - virtual bool user_create() ; - // @cmember Distruzione dei dati dell'utente - virtual bool user_destroy() ; - // @cmember Chiama il programma di stampa - virtual void print(); - // @cmember Riscrive sulla relazione i valori dalla maschera

- virtual int rewrite(const TMask& m); - // @cmember imposta sulla maschera la descrizione - virtual void set_descr(TMask & m, const TString & desc) {} + // Chiamata nella user_create: instanzia la vera TAutomask da usare + virtual TMask* user_create_mask(); // @access Public Member public: - // @cmember Ritorna il nome della tabella - const TString& get_tabname() const - { return _tabname; } - virtual bool find(word key = 0); - - // @cmember Costruttore - TMultirel_application(); - // @cmember Distruttore - virtual ~TMultirel_application(); }; #endif diff --git a/include/prefix.cpp b/include/prefix.cpp index ccb5a1fa7..0fc4d269a 100755 --- a/include/prefix.cpp +++ b/include/prefix.cpp @@ -1441,8 +1441,17 @@ int TTable_names::logic_num(const TString& n) // ATTENZIONE: NON includere qui MAG! if (namelen == 3 && name != "DOC" && name != "MOV" && name != "RIP" && name != "CDC") return LF_TAB; - if (namelen == 4 && name[0] == '%') - return LF_TABCOM; + if (namelen == 4) + { + switch (name[0]) + { + case '^': return LF_TABGEN; + case '%': return LF_TABCOM; + case '$': return LF_TAB; + case '&': return LF_TABMOD; + default : break; + } + } TString* str = (TString*)_names.objptr(name); if (str == NULL) diff --git a/include/relation.cpp b/include/relation.cpp index 1299e1493..ec18d63fa 100755 --- a/include/relation.cpp +++ b/include/relation.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -14,7 +15,28 @@ // *** check if not already defined #define NOTFOUND (-1) -#define print_name(out, f) out << (f.num() == LF_TABCOM ? "%" : "") << f.name() +HIDDEN void print_name(ostream& out, const TLocalisamfile& f) +{ + switch (f.num()) + { + case LF_TABCOM: out << '%'; break; + case LF_TABMOD: out << '&'; break; + default: break; + } + out << f.name(); +} + +HIDDEN void print_name(TToken_string& out, const TLocalisamfile& f) +{ + switch (f.num()) + { + case LF_TABCOM: out << '%'; break; + case LF_TABMOD: out << '&'; break; + default: break; + } + out << f.name(); +} + extern int get_error(int); @@ -178,7 +200,7 @@ void TRelationdef::print_on(TToken_string& out) const { const TLocalisamfile& f = _rel->file(_num); - out = ""; + out.cut(0); print_name(out, f); // add description @@ -256,17 +278,19 @@ TRelation::TRelation(int logicnum) } TRelation::TRelation(const char* tabname) -: _files(4), _reldefs(4), _errors(NOERR) + : _files(4), _reldefs(4), _errors(NOERR) { - TTable* t = new TTable(tabname); + TLocalisamfile* t = NULL; + if (tabname[0] == '&') + t = new TModule_table(tabname); + else + t = new TTable(tabname); _files.add(t); } TRelation::TRelation(TLocalisamfile* l) -: _files(4), _reldefs(4), _errors(NOERR) -{ - _files.add(l); -} + : _files(4), _reldefs(4), _errors(NOERR) +{ _files.add(l); } TRelation::~TRelation() {} @@ -2117,7 +2141,7 @@ TObject* TFieldref::dup() const TFieldref& TFieldref::operator =( const TString& s) // @parm Stringa da assegnare all'oggetto -// @comm Un deve avere il seguente formato (solamente NAME e il mandante): +// @comm Un deve avere il seguente formato (solamente NAME e il mandante): // FILE->NAME[FROM,TO] { diff --git a/include/tabmod.cpp b/include/tabmod.cpp index f0d4bf276..92cf9badd 100755 --- a/include/tabmod.cpp +++ b/include/tabmod.cpp @@ -1,28 +1,24 @@ #include -#include +#include #include -#include -#include -#include -#include - - -TModule_table::TModule_table(const char* tabname, const char * module, long customer) -: TLocalisamfile(LF_TABGEN), _tabname(tabname), _module(module), _customer(customer) +TModule_table::TModule_table(const char* tabname, const char* module, long customer) + : TLocalisamfile(LF_TABMOD), _tabname(tabname), + _module(module), _customer(customer) { TFilename app = main_app().argv(0); app.ext(""); - const TString16 appname = app.name(); + const TFixed_string appname(app.name()); if (_module.blank()) _module = appname.left(2); + _module.upper(); + if (!isalpha(_tabname[0])) // Toglie eventuali prefissi inutili d'ora in poi + _tabname.ltrim(1); _tabname.upper(); - _module.lower(); - if (_customer == 0L && real::is_natural(app.mid(3))) - _customer = atol(app.mid(2)); - _des_mod_loaded = FALSE; + if (_customer <= 0L && real::is_natural(appname.mid(3))) + _customer = atol(app.mid(2)); } // @cmember Vuota tutto il record usando il carattere

void TModule_table::zero(char c) @@ -40,52 +36,49 @@ void TModule_table::zero(TRectype & rec, char c) bool TModule_table::in_table() const { - const TRectype & rec = curr(); + const TRectype& rec = curr(); return _tabname == rec.get("COD") && _module == rec.get("MOD") && _customer == rec.get_long("CUST"); } int TModule_table::skip(TRecnotype nrec, word lockop) - { - if (!nrec) return NOERR; - TBaseisamfile::skip(nrec, lockop); - if (not_in_table()) + if (nrec == 0) + return NOERR; + int err = TBaseisamfile::skip(nrec, lockop); + if (err == NOERR && not_in_table()) { + if (lockop == _lock || lockop == _testandlock) + TBaseisamfile::reread(_unlock); if (nrec > 0) { - if (lockop == _lock) - TBaseisamfile::reread(_unlock); last(lockop); - setstatus(_iseof); + setstatus(err = _iseof); } else { - if (lockop == _lock) - TBaseisamfile::reread(_unlock); first(lockop); - setstatus(_isbof); + setstatus(err = _isbof); } } - return status(); + return err; } - int TModule_table::_read(TRectype& rec, word op, word lockop) - { - - if (op == _isfirst) + switch (op) { - zero(rec); - TBaseisamfile::_read(rec, _isgteq, lockop); - - if (not_in_table()) - setstatus(_isemptyfile); - if (bad()) + case _isfirst: + { zero(rec); - } - else - if (op == _islast) + TBaseisamfile::_read(rec, _isgteq, lockop); + + if (not_in_table()) + setstatus(_isemptyfile); + if (bad()) + zero(rec); + } + break; + case _islast: { zero(rec); put("CODTAB", "\xFF"); @@ -101,45 +94,49 @@ int TModule_table::_read(TRectype& rec, word op, word lockop) if (bad()) zero(rec); } - else - if (op == _isprev) + break; + case _isprev: + { + const TRecnotype nrec = recno(); + TBaseisamfile::_read(rec, _isprev, lockop); + if (not_in_table()) { - const TRecnotype nrec = recno(); - - TBaseisamfile::_read(rec, _isprev, lockop); - if (not_in_table()) - { - if (lockop == _lock) reread(_unlock); - readat(rec, nrec, lockop); - setstatus(_isbof); - } + if (lockop == _lock || lockop == _testandlock) + reread(_unlock); + readat(rec, nrec, lockop); + setstatus(_isbof); } - else - if (op == _isnext) + } + break; + case _isnext: + { + const TRecnotype nrec = recno(); + TBaseisamfile::_read(rec, _isnext, lockop); + if (not_in_table()) { - const TRecnotype nrec = recno(); - - TBaseisamfile::_read(rec, _isnext, lockop); - if (not_in_table()) - { - if (lockop == _lock) reread(_unlock); - readat(rec, nrec, lockop); - setstatus(_iseof); - } + if (lockop == _lock || lockop == _testandlock) + reread(_unlock); + readat(rec, nrec, lockop); + setstatus(_iseof); } - else + } + break; + default: // read normale + { + rec.put("COD", _tabname); + rec.put("MOD", _module); + rec.put("CUST", _customer); + TBaseisamfile::_read(rec, op, lockop); + if (not_in_table()) { - rec.put("COD", _tabname); - rec.put("MOD", _module); - rec.put("CUST", _customer); - TBaseisamfile::_read(rec, op, lockop); - if (not_in_table()) - { - if (lockop == _lock) reread(_unlock); - last(lockop); - setstatus(_iseof); - } - } + if (lockop == _lock || lockop == _testandlock) + reread(_unlock); + last(lockop); + setstatus(_iseof); + } + } + break; + } return status(); } @@ -165,135 +162,77 @@ void TModule_table::load_module_description() // cerca se esiste il file ??.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 (n.exist()) + n = _module; + if (_customer > 0) { - TConfig des(n, "TabDescr"); - _module = des.get("Module"); + TString8 c; + c.format("%06ld", _customer); + n << c; } - n = "??tb"; n << _tabname; n.ext("msk"); - n.lower(); - TString_array f; - if (list_files(n, f) == 1) + if (n.exist()) { - n = f.row(0); - if (!n.exist()) - n.overwrite("ba",0); - if (n.exist()) + TScanner m(n); + bool ok = true; + while (ok) { - if (_module.empty()) - { - _module = n.left(2); - _module.lower(); - } - 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"; + 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); + } + } + if (_description.blank()) + { + _description = TR("Tabella"); + _description << ' ' << _tabname << ' ' << TR("Modulo") << ' ' << _module; + if (_customer > 0) + _description << _customer; } - else - _module = "ba"; } -const char* TModule_table::module() -{ - if (!_des_mod_loaded) - load_module_description(); - return _module; -} +const char* TModule_table::module() const +{ return _module; } + +long TModule_table::customer() const +{ return _customer; } const char* TModule_table::description() { - if (!_des_mod_loaded) + if (_description.empty()) load_module_description(); return _description; } -struct TCallbackTableinfo -{ - TString16 _var1, _var2, _var3; - TString4 _module; - TFilename _tabapp, _relapp; -}; - -HIDDEN int find_relapp(TConfig& cfg, void* jolly) -{ - TCallbackTableinfo& info = *((TCallbackTableinfo*)jolly); - - if (cfg.exist(info._var1)) - { - info._tabapp = cfg.get(info._var1); - if (info._tabapp.not_empty()) - return 1; - } - if (cfg.get_paragraph().compare(info._module, 2, TRUE) == 0) - { - if (cfg.exist(info._var2)) - { - info._relapp = cfg.get(info._var2); - if (info._relapp.not_empty()) - return 2; - } - if (cfg.exist(info._var3)) - { - info._relapp = cfg.get(info._var3); - if (info._relapp.not_empty()) - return 3; - } - } - return 0; -} - bool TModule_table::get_relapp(TString& app) const { - TConfig ini("install.ini"); - TCallbackTableinfo fi; - fi._var1.format("Edit_%s", (const char*)_tabname); - fi._var2.format("Edit_%d", num()); - fi._var3.format("Edit_%d", num() == LF_TAB ? LF_TABCOM : LF_TAB); - fi._module = ((TModule_table*)this)->module(); - ini.for_each_paragraph(find_relapp, &fi); + TString8 para = _module; + if (_customer > 0L) + para.format("%s%06ld", (const char*)_module, _customer); + para.lower(); + TConfig ini("install.ini", para); - app = fi._tabapp; - if (app.empty()) - app = fi._relapp; + TString8 var; + var << "Edit_" << _tabname; + app = ini.get(var); if (app.empty()) { - app = "ba3 -0"; - if (fi._module.compare("ba", 2, TRUE) != 0) - { - TConfig c(CONFIG_STUDIO, fi._module); - if (c.exist("TabPrg")) - app = c.get("TabPrg"); - } + var.cut(0) << "Edit_" << LF_TABMOD; + app = ini.get(var); + if (app.empty()) + app << _module << "0 -0"; } - app << ' '; - if (num() == LF_TABCOM) - app << '%'; - app << _tabname; return app.not_empty(); } diff --git a/include/tabmod.h b/include/tabmod.h index 81081cd46..52176e260 100755 --- a/include/tabmod.h +++ b/include/tabmod.h @@ -24,8 +24,6 @@ class TModule_table : public TLocalisamfile long _customer; // @cmember:(INTERNAL) Descrizione della tabella TString _description; - // @cmember:(INTERNAL) Flag che indica l'avvenuto caricamento di descrizione e modulo - bool _des_mod_loaded; // @access Protected Member protected: @@ -48,7 +46,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(); + const char* module() const; + // @cmember Ritorna il cliente al quale appartiene la tabella + long customer() const; + // @cmember Ritorna la descrizione della tabella virtual const char* description(); // @controlla se la tabella e' vuota