Aggiustate cazzatelle in isam.cpp

git-svn-id: svn://10.65.10.50/trunk@295 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
villa 1994-09-28 10:36:08 +00:00
parent 0dbd85e23c
commit 4777de77d9
20 changed files with 644 additions and 644 deletions

View File

@ -18,15 +18,15 @@ bool TConfig_application::create()
{ {
arg = argv(i); arg = argv(i);
if (arg == "-c") if (arg == "-c")
_which_config = atoi(argv(++i)); _which_config = atoi(argv(++i));
else else
if (arg[0] == '-') if (arg[0] == '-')
continue; continue;
else else
{ {
TString* argp = new TString(arg); TString* argp = new TString(arg);
_paragraphs.add(argp); _paragraphs.add(argp);
} }
} }
user_create(); user_create();
@ -45,83 +45,83 @@ bool TConfig_application::menu(MENU_TAG m)
{ {
// funziona da se' fino a 20 voci della menubar // funziona da se' fino a 20 voci della menubar
if (m >= BAR_ITEM(1) && m <= BAR_ITEM(20)) if (m >= BAR_ITEM(1) && m <= BAR_ITEM(20))
{ {
_last_choice = m; _last_choice = m;
do_config((m - BAR_ITEM(0))/100); do_config((m - BAR_ITEM(0))/100);
} }
return xvt_test_menu_tag(BAR_ITEM(2)); return xvt_test_menu_tag(BAR_ITEM(2));
} }
void TConfig_application::do_config(int m) void TConfig_application::do_config(int m)
{ {
for (;;) for (;;)
{
TString par = name();
if (m < _paragraphs.items())
par = (TString&)_paragraphs[m];
else par.cut(2);
TConfig cnf(_which_config, par);
TString maskname(cnf.get("EdMask"));
if (!maskname.empty())
{ {
TString par = name(); TMask m(maskname);
if (m < _paragraphs.items())
par = (TString&)_paragraphs[m]; // carica campi
else par.cut(2); for (int i = 0; i < m.fields(); i++)
{
TMask_field& f = m.fld(i);
const TFieldref* fref = f.field();
if (fref != NULL)
{
const char* fname = fref->name();
if (fname != NULL)
{
TString& oldvl = cnf.get(fname);
if (!oldvl.empty())
f.set(oldvl);
}
}
}
// run mask
if (!preprocess_config(m,cnf))
break;
TConfig cnf(_which_config, par); int k = m.run();
if (!postprocess_config(m,cnf))
TString maskname(cnf.get("EdMask")); break;
if (!maskname.empty())
{
TMask m(maskname);
// carica campi
for (int i = 0; i < m.fields(); i++)
{
TMask_field& f = m.fld(i);
const TFieldref* fref = f.field();
if (fref != NULL)
{
const char* fname = fref->name();
if (fname != NULL)
{
TString& oldvl = cnf.get(fname);
if (!oldvl.empty())
f.set(oldvl);
}
}
}
// run mask
if (!preprocess_config(m,cnf))
break;
int k = m.run(); if (k == K_ENTER)
if (!postprocess_config(m,cnf)) {
break; // aggiusta campi
for (i = 0; i < m.fields(); i++)
if (k == K_ENTER) {
{ TMask_field& f = m.fld(i);
// aggiusta campi if (f.dirty())
for (i = 0; i < m.fields(); i++) {
{ const TFieldref* fref = f.field();
TMask_field& f = m.fld(i); if (fref != NULL)
if (f.dirty()) {
{ const char* fname = fref->name();
const TFieldref* fref = f.field(); const char* value = f.get();
if (fref != NULL) const char* oldvl = cnf.get(fname);
{ if (postprocess_config_changed(par,fname,
const char* fname = fref->name(); oldvl,value))
const char* value = f.get(); cnf.set(fname, value, NULL, TRUE);
const char* oldvl = cnf.get(fname); }
if (postprocess_config_changed(par,fname, }
oldvl,value)) }
cnf.set(fname, value, NULL, TRUE); }
} else break;
}
}
}
else break;
}
else
{
warning_box("Nessun parametro da configurare");
break;
}
} }
else
{
warning_box("Nessun parametro da configurare");
break;
}
}
} }
bool TConfig_application::preprocess_config (TMask& mask, TConfig& config) bool TConfig_application::preprocess_config (TMask& mask, TConfig& config)
@ -135,9 +135,9 @@ bool TConfig_application::postprocess_config (TMask& mask, TConfig& config)
} }
bool TConfig_application::postprocess_config_changed(const char* par, bool TConfig_application::postprocess_config_changed(const char* par,
const char* var, const char* var,
const char* oldv, const char* oldv,
const char* newv) const char* newv)
{ {
return TRUE; return TRUE;
} }

View File

@ -35,7 +35,7 @@ class TConfig_application : public TApplication
{ {
TArray _paragraphs; TArray _paragraphs;
int _which_config; int _which_config;
MENU_TAG _last_choice; MENU_TAG _last_choice;
virtual bool create(); virtual bool create();
@ -44,7 +44,7 @@ class TConfig_application : public TApplication
void do_config(int m); void do_config(int m);
protected: protected:
virtual bool user_create() { return TRUE; } virtual bool user_create() { return TRUE; }
virtual bool user_destroy() { return TRUE; } virtual bool user_destroy() { return TRUE; }
@ -54,23 +54,23 @@ class TConfig_application : public TApplication
virtual bool preprocess_config (TMask& mask, TConfig& config); virtual bool preprocess_config (TMask& mask, TConfig& config);
// questa viene chiamata dopo e blocca tutto se FALSE // questa viene chiamata dopo e blocca tutto se FALSE
virtual bool postprocess_config (TMask& mask, TConfig& config); virtual bool postprocess_config (TMask& mask, TConfig& config);
// questa e' come la change_config di application ma viene usata // questa e' come la change_config di application ma viene usata
// dalla maschera principale; le viene passato in piu' il paragrafo // dalla maschera principale; le viene passato in piu' il paragrafo
// in corso di editing. E' chiamata per ogni parametro modificato // in corso di editing. E' chiamata per ogni parametro modificato
// Se ritorna FALSE la modifica non viene accettata; default ritorna // Se ritorna FALSE la modifica non viene accettata; default ritorna
// TRUE e non rompe i bal // TRUE e non rompe i bal
virtual bool postprocess_config_changed (const char* par, const char* var, virtual bool postprocess_config_changed (const char* par, const char* var,
const char* oldv, const char* newv); const char* oldv, const char* newv);
public: public:
TConfig_application(int which_config = CONFIG_GENERAL) TConfig_application(int which_config = CONFIG_GENERAL)
: _which_config(which_config) : _which_config(which_config)
{} {}
virtual ~TConfig_application() virtual ~TConfig_application()
{} {}
}; };
#endif #endif

View File

@ -2,8 +2,8 @@
#define __DEFMASK_H #define __DEFMASK_H
/* @M /* @M
Identificativi predefiniti dei controlli di XVT Identificativi predefiniti dei controlli di XVT
*/ */
#define DLG_NULL -1 #define DLG_NULL -1
#define DLG_OK 1 /* TAG del bottone <Conferma> */ #define DLG_OK 1 /* TAG del bottone <Conferma> */
#define DLG_CANCEL 2 /* TAG del bottone <Annulla> */ #define DLG_CANCEL 2 /* TAG del bottone <Annulla> */
@ -30,31 +30,31 @@ Identificativi predefiniti dei controlli di XVT
#define DLG_USER 100 /* TAG del primo controllo definito dall'utente */ #define DLG_USER 100 /* TAG del primo controllo definito dall'utente */
/* @M /* @M
Funzioni di libreria per i validate delle maschere Funzioni di libreria per i validate delle maschere
Nome descrizione Parametri Nome descrizione Parametri
NUM_EXPR espressione numerica espressione NUM_EXPR espressione numerica espressione
STR_EXPR espressione stringa espressione STR_EXPR espressione stringa espressione
NOT_EMPTY_FUNC campo non vuoto NOT_EMPTY_FUNC campo non vuoto
FIXLEN_FUNC lunghezza fissa lunghezza FIXLEN_FUNC lunghezza fissa lunghezza
EMPTYCOPY_FUNC data id del campo da cui copiarsi se vuoto EMPTYCOPY_FUNC data id del campo da cui copiarsi se vuoto
DATE_CMP_FUNC compara due date operatore,id.campo con l'altra DATE_CMP_FUNC compara due date operatore,id.campo con l'altra
data data
PI_FUNC controllo part.IVA ???? PI_FUNC controllo part.IVA ????
XTPI_FUNC controllo esteso XTPI_FUNC controllo esteso
part.IVA ???? part.IVA ????
XTZPI_FUNC controllo esteso XTZPI_FUNC controllo esteso
part.IVA anche vuota ???? part.IVA anche vuota ????
CF_FUNC controllo cod.fisc. ???? CF_FUNC controllo cod.fisc. ????
XTCF_FUNC controllo esteso XTCF_FUNC controllo esteso
cod.fisc. ???? cod.fisc. ????
XTZCF_FUNC controllo esteso XTZCF_FUNC controllo esteso
cod.fisc.anche vuoto ???? cod.fisc.anche vuoto ????
MTCHECK_FUNC mese corretto per MTCHECK_FUNC mese corretto per
ditta mensile o ditta mensile o
trimestrale trimestrale
REQIF_FUNC richiesto se immesso REQIF_FUNC richiesto se immesso
un campo della lista n.ro di campi lista di campi... un campo della lista n.ro di campi lista di campi...
*/ */
#define EXPR_FUNC 0 2 #define EXPR_FUNC 0 2
#define EMPTYCOPY_FUNC 1 1 #define EMPTYCOPY_FUNC 1 1

View File

@ -17,9 +17,9 @@
class TExternal_app : public TObject class TExternal_app : public TObject
{ {
const char* _path; // app name (must be allocated by user) const char* _path; // app name (must be allocated by user)
int _error; // last error (errno code) int _error; // last error (errno code)
int _exitcode; // last exit code int _exitcode; // last exit code
int _count; // count of calls int _count; // count of calls
public: public:

View File

@ -18,42 +18,42 @@
// @T // @T
enum TCodesym { _invalid, _endsym, _comma, _lpar, _rpar, _variable, enum TCodesym { _invalid, _endsym, _comma, _lpar, _rpar, _variable,
_number, _string, _plus, _minus, _multiply, _divide, _number, _string, _plus, _minus, _multiply, _divide,
_chgs, _and, _or, _not, _equal, _match, _noteq, _lt, _gt, _chgs, _and, _or, _not, _equal, _match, _noteq, _lt, _gt,
_lteq, _gteq, _sqrt, _sqr, _exp10, _exp, _log10, _log, _lteq, _gteq, _sqrt, _sqr, _exp10, _exp, _log10, _log,
_sin, _cos, _tan, _left, _right, _pow, _min, _max, _mid, _sin, _cos, _tan, _left, _right, _pow, _min, _max, _mid,
_upper } ; _upper } ;
// @DES I tipi di espressioni definiti // @DES I tipi di espressioni definiti
// @T // @T
enum TTypeexp { _numexpr, _strexpr } ; enum TTypeexp { _numexpr, _strexpr } ;
// @END // @END
// @C // @C
// Classe TValue : public TObject // Classe TValue : public TObject
// @END // @END
class TValue : public TObject class TValue : public TObject
{ {
// @DPRIV // @DPRIV
real _r; // Valore real real _r; // Valore real
TString _s; // Valore in formato stringa TString _s; // Valore in formato stringa
public: public:
// @FPUB // @FPUB
TValue& operator =(const TValue& val) { _s = val._s; _r = val._r; return *this;} // Operatore = tra oggetti TValue TValue& operator =(const TValue& val) { _s = val._s; _r = val._r; return *this;} // Operatore = tra oggetti TValue
const real& number() const { return _r;} // Ritorna il valore numerico const real& number() const { return _r;} // Ritorna il valore numerico
const char* string() const { return (const char*) _s;} // Ritorna il valore come stringa const char* string() const { return (const char*) _s;} // Ritorna il valore come stringa
void set(const real& val) { _r = val; _s = val.string();} // Real void set(const real& val) { _r = val; _s = val.string();} // Real
void set(const char* val) { _s = val; _r = real(val);} // Stringa void set(const char* val) { _s = val; _r = real(val);} // Stringa
// @DES Costruttori. Inizializzano TValue con vari oggetti // @DES Costruttori. Inizializzano TValue con vari oggetti
// @FPUB // @FPUB
TValue(const real& val) { _r = val; _s = val.string();} // Real TValue(const real& val) { _r = val; _s = val.string();} // Real
TValue(const char* val) { _s = val; _r = real(val);} // Stringa TValue(const char* val) { _s = val; _r = real(val);} // Stringa
TValue(const TValue& val) { *this = val; } // Altro TValue TValue(const TValue& val) { *this = val; } // Altro TValue
TValue() { _r = 0.00; _s = ""; } // 0,0 e "" TValue() { _r = 0.00; _s = ""; } // 0,0 e ""
}; };
@ -73,20 +73,20 @@ extern TValue nulltvalue;
class TCode : public TObject class TCode : public TObject
{ {
// @DPRIV // @DPRIV
TCodesym _sym; // Simbolo-istruzione-codice TCodesym _sym; // Simbolo-istruzione-codice
TValue _val; // Valore TValue _val; // Valore
public: public:
// @FPUB // @FPUB
TCode& operator =(const TCode& b); TCode& operator =(const TCode& b);
void set(TCodesym sym, const TValue& val = nulltvalue) { _sym = sym; _val = val; } // Inizializza simbolo = sym e valore = val void set(TCodesym sym, const TValue& val = nulltvalue) { _sym = sym; _val = val; } // Inizializza simbolo = sym e valore = val
TCodesym getsym() const { return _sym;} // Ritorna il simbolo _sym TCodesym getsym() const { return _sym;} // Ritorna il simbolo _sym
const real& number() const { return _val.number();} // Ritorna il valore _val come real const real& number() const { return _val.number();} // Ritorna il valore _val come real
const char* string() const { return _val.string();} // Ritorna il valore _val come stringa const char* string() const { return _val.string();} // Ritorna il valore _val come stringa
TCode() {set(_invalid);} // Costruttore, inizializza simbolo con "invalid", valore a nullvalue TCode() {set(_invalid);} // Costruttore, inizializza simbolo con "invalid", valore a nullvalue
TCode(TCodesym sym, const TValue& val = nulltvalue) { set(sym, val);} // Costruttore, inizializza simbolo con sym e valore con val TCode(TCodesym sym, const TValue& val = nulltvalue) { set(sym, val);} // Costruttore, inizializza simbolo con sym e valore con val
}; };
// @C // @C
@ -98,21 +98,21 @@ class TCode : public TObject
class TCodearray : public TObject class TCodearray : public TObject
{ {
// @DPRIV // @DPRIV
int _last; // Numero di istruzioni int _last; // Numero di istruzioni
int _ip; // Puntatore all'istruzione corrente (Istruction pointer) int _ip; // Puntatore all'istruzione corrente (Istruction pointer)
TArray _rpn; // Array TArray _rpn; // Array
// @END // @END
public: public:
// @FPUB // @FPUB
void clear(); // Cancella contenuto array void clear(); // Cancella contenuto array
void add(TCodesym sym, const TValue& val = nulltvalue); // Aggiunge un'istruzione all'array void add(TCodesym sym, const TValue& val = nulltvalue); // Aggiunge un'istruzione all'array
void begin() { _ip = 0;} // Mette all'inizio il puntatore all'istruzione corrente void begin() { _ip = 0;} // Mette all'inizio il puntatore all'istruzione corrente
TCode& step() { return (TCode&) _rpn[end() ? _ip : _ip++];} // Incrementa istruction pointer TCode& step() { return (TCode&) _rpn[end() ? _ip : _ip++];} // Incrementa istruction pointer
bool end() const { return ((TCode&) _rpn[_ip]).getsym() == _endsym;} // Ritorna vero se _ip ha raggiunto il simbolo di fine codice bool end() const { return ((TCode&) _rpn[_ip]).getsym() == _endsym;} // Ritorna vero se _ip ha raggiunto il simbolo di fine codice
void backtrace(int step = 1) { _ip > step ? _ip -= step : begin(); } void backtrace(int step = 1) { _ip > step ? _ip -= step : begin(); }
TCodearray(int size = 50); // Il costruttore crea un array di 10 elementi TCodearray(int size = 50); // Il costruttore crea un array di 10 elementi
}; };
// @C // @C
@ -121,31 +121,31 @@ class TCodearray : public TObject
class TVar : public TObject class TVar : public TObject
{ {
// @DPRIV // @DPRIV
TString _name; // Nome variabile TString _name; // Nome variabile
TValue _val; // Valore TValue _val; // Valore
public: public:
// @DES Operatore = tra vari oggetti // @DES Operatore = tra vari oggetti
// @FPUB // @FPUB
const char* operator =(const char* val) { _val.set(val); return val;} const char* operator =(const char* val) { _val.set(val); return val;}
const real& operator =(const real& val) { _val.set(val); return val;} const real& operator =(const real& val) { _val.set(val); return val;}
TVar& operator =(const TValue& val) { _val = val; return *this;} TVar& operator =(const TValue& val) { _val = val; return *this;}
TVar& operator =(const TVar& var) { _name = var._name ; _val = var._val; return *this;} TVar& operator =(const TVar& var) { _name = var._name ; _val = var._val; return *this;}
void set(const char* name, const TValue& val = nulltvalue) { _name = name ; _val = val;} void set(const char* name, const TValue& val = nulltvalue) { _name = name ; _val = val;}
void setname(const char* name) { _name = name;} // Setta a name il nome della variabile void setname(const char* name) { _name = name;} // Setta a name il nome della variabile
const char* getname() const { return _name;} // Ritorna il nome della variabile const char* getname() const { return _name;} // Ritorna il nome della variabile
operator TValue&() { return _val;} // Ritorna _val (un TValue) operator TValue&() { return _val;} // Ritorna _val (un TValue)
const real& number() const { return _val.number();} // Ritorna il valore real della variabile const real& number() const { return _val.number();} // Ritorna il valore real della variabile
const char* string() const { return _val.string();} // Ritorna il valore stringa della variabile const char* string() const { return _val.string();} // Ritorna il valore stringa della variabile
// @DES Costruttori // @DES Costruttori
// @FPUB // @FPUB
TVar() { _name = ""; _val = nulltvalue;} TVar() { _name = ""; _val = nulltvalue;}
TVar(const char* name, const TValue& val = nulltvalue) { _name = name; _val = val;} TVar(const char* name, const TValue& val = nulltvalue) { _name = name; _val = val;}
TVar(TVar& v) { _name = v._name; _val = v._val;} TVar(TVar& v) { _name = v._name; _val = v._val;}
}; };
// @C // @C
@ -154,35 +154,35 @@ class TVar : public TObject
class TVararray : public TObject class TVararray : public TObject
{ {
// @DPRIV // @DPRIV
int _last; // Numero di variabili int _last; // Numero di variabili
TArray _array; // Array TArray _array; // Array
// @END // @END
public: public:
// @FPUB // @FPUB
void clear() { _last = 0; } // Cancella contenuto array void clear() { _last = 0; } // Cancella contenuto array
void add(const TVar& var); // Aggiunge un oggetto TVar void add(const TVar& var); // Aggiunge un oggetto TVar
void add(const char* name, const TValue& val = nulltvalue); // Aggiunge un nome di variabile e il suo valore void add(const char* name, const TValue& val = nulltvalue); // Aggiunge un nome di variabile e il suo valore
const char* varname(int varnum) const { return varnum < _array.items() ? ((TVar&) _array[varnum]).getname() : "";} // Ritorna il nome della variabile di posto varnum const char* varname(int varnum) const { return varnum < _array.items() ? ((TVar&) _array[varnum]).getname() : "";} // Ritorna il nome della variabile di posto varnum
// @DES Metodi di inizializzazione // @DES Metodi di inizializzazione
// @FPUB // @FPUB
void set(const char* varname, const real& val); void set(const char* varname, const real& val);
void set(const char* varname, const char* val); void set(const char* varname, const char* val);
void set(int varnum, const real& val) { if (varnum < _array.items()) ((TVar&) _array[varnum]) = val;} void set(int varnum, const real& val) { if (varnum < _array.items()) ((TVar&) _array[varnum]) = val;}
void set(int varnum, const char* val) { if (varnum < _array.items()) ((TVar&) _array[varnum]) = val;} void set(int varnum, const char* val) { if (varnum < _array.items()) ((TVar&) _array[varnum]) = val;}
// @DES Metodi di interrogazione // @DES Metodi di interrogazione
// @FPUB // @FPUB
const real& getnum(const char* varname); const real& getnum(const char* varname);
const real& getnum(int varnum); const real& getnum(int varnum);
const char* getstring(const char* varname); const char* getstring(const char* varname);
const char* getstring(int varnum); const char* getstring(int varnum);
int numvar() const { return _last;} // Ritorna il numero di variabili utilizzate int numvar() const { return _last;} // Ritorna il numero di variabili utilizzate
TVararray(int size = 10); TVararray(int size = 10);
}; };
// @C // @C
@ -191,52 +191,52 @@ class TVararray : public TObject
class TExpression : public TObject class TExpression : public TObject
{ {
// @DPRIV // @DPRIV
TCodearray _code; // Array di codice TCodearray _code; // Array di codice
TVararray _var; // Array di variabili TVararray _var; // Array di variabili
TValue _val; // Valore dell'espressione TValue _val; // Valore dell'espressione
bool _dirty; // Vero se l'espressione e' stata modificata bool _dirty; // Vero se l'espressione e' stata modificata
TTypeexp _type; // Tipo dell'espressione TTypeexp _type; // Tipo dell'espressione
TString _original; // stringa originale TString _original; // stringa originale
// @END // @END
// @FPROT // @FPROT
protected: protected:
void eval(); // Valuta l'espressione void eval(); // Valuta l'espressione
TCodesym __gettoken(bool reduct = FALSE); TCodesym __gettoken(bool reduct = FALSE);
TCodesym __factor(TCodesym startsym); TCodesym __factor(TCodesym startsym);
TCodesym __term(TCodesym startsym); TCodesym __term(TCodesym startsym);
TCodesym __expression(TCodesym startsym); TCodesym __expression(TCodesym startsym);
virtual void print_on(ostream& out) const ; virtual void print_on(ostream& out) const ;
bool compile(const char* expression, TTypeexp type); // Compila l'espressione bool compile(const char* expression, TTypeexp type); // Compila l'espressione
public: public:
// @FPUB // @FPUB
operator const real&(); // Ritorna il valore real dell'espressione operator const real&(); // Ritorna il valore real dell'espressione
operator const char*(); // Ritorna il valore come stringa operator const char*(); // Ritorna il valore come stringa
operator bool(); // Ritorna il valore come booleano operator bool(); // Ritorna il valore come booleano
// @DES Metodi di interrogazione // @DES Metodi di interrogazione
// @FPUB // @FPUB
// Ritorna il nome della variabile di posto varnum // Ritorna il nome della variabile di posto varnum
const char* varname(int varnum) const { return _var.varname(varnum); } const char* varname(int varnum) const { return _var.varname(varnum); }
// Ritorna il numero di variabili nell'espressione // Ritorna il numero di variabili nell'espressione
int numvar() const { return _var.numvar(); } int numvar() const { return _var.numvar(); }
const TTypeexp type() const { return _type; } const TTypeexp type() const { return _type; }
TCodearray& code() const { return (TCodearray&)_code; } TCodearray& code() const { return (TCodearray&)_code; }
const TVararray& vars() const { return _var; } const TVararray& vars() const { return _var; }
// @DES Metodi di inizializzazione // @DES Metodi di inizializzazione
// @FPUB // @FPUB
void setvar(const char* varname, const real& val); void setvar(const char* varname, const real& val);
void setvar(int varnum, const real& val); void setvar(int varnum, const real& val);
void setvar(const char* varname, const char* val); void setvar(const char* varname, const char* val);
void setvar(int varnum, const char* val); void setvar(int varnum, const char* val);
void set_type(const TTypeexp type) { _type = type; } void set_type(const TTypeexp type) { _type = type; }
bool set(const char* expression, TTypeexp type = _numexpr); bool set(const char* expression, TTypeexp type = _numexpr);
TExpression(const char* expression, TTypeexp type = _numexpr); TExpression(const char* expression, TTypeexp type = _numexpr);
TExpression(TTypeexp type = _numexpr); TExpression(TTypeexp type = _numexpr);
}; };
#endif // __EXPR_H #endif // __EXPR_H

View File

@ -1,7 +1,7 @@
#ifndef __EXTCTYPE_H #ifndef __EXTCTYPE_H
#define __EXTCTYPE_H #define __EXTCTYPE_H
#ifndef __STDTTYPES_H #ifndef __STDTTYPES_H
#include <stdtypes.h> #include <stdtypes.h>
#endif #endif
@ -131,7 +131,7 @@ typedef struct
INT16 KeyLen __PACKED__ ; INT16 KeyLen __PACKED__ ;
bool DupKeys __PACKED__ ; bool DupKeys __PACKED__ ;
#ifdef __PACK_1__ #ifdef __PACK_1__
byte junk; byte junk;
#endif #endif
INT16 NKNode __PACKED__ ; INT16 NKNode __PACKED__ ;
INT16 MaxKNode __PACKED__ ; INT16 MaxKNode __PACKED__ ;
@ -146,7 +146,7 @@ typedef struct
{ {
byte TPage __PACKED__ ; byte TPage __PACKED__ ;
#ifdef __PACK_1__ #ifdef __PACK_1__
byte junk; byte junk;
#endif #endif
INT16 PathNumber __PACKED__ ; INT16 PathNumber __PACKED__ ;
INT16 Flags __PACKED__ ; INT16 Flags __PACKED__ ;

View File

@ -798,7 +798,7 @@ long TSystemisamfile::size(TRecnotype eox)
#ifndef FOXPRO #ifndef FOXPRO
bool TSystemisamfile::getlcf(int flev) bool TSystemisamfile::getlcf(long flev)
{ {
_flds.destroy(); _flds.destroy();

View File

@ -346,7 +346,7 @@ class TSystemisamfile : public TIsamfile
TArray _flds; TArray _flds;
TArray _exps; TArray _exps;
bool getlcf(int flev); bool getlcf(long flev);
void makelc(TRectype& rec); void makelc(TRectype& rec);
public: public:

View File

@ -1,4 +1,4 @@
// $Id: mailbox.cpp,v 1.2 1994-09-19 09:49:41 villa Exp $ // $Id: mailbox.cpp,v 1.3 1994-09-28 10:35:45 villa Exp $
#include <stdlib.h> #include <stdlib.h>
#include <fstream.h> #include <fstream.h>
@ -17,44 +17,44 @@
#define MAX_TXT_LEN 200 #define MAX_TXT_LEN 200
TMessage::TMessage(const char* to, const char* sub, const char* text, TMessage::TMessage(const char* to, const char* sub, const char* text,
const char* from) const char* from)
{ {
_to = to; _subject = sub; _to = to; _subject = sub;
_text = text; _text = text;
_from = (from == NULL ? MainApp()->name() : from); _from = (from == NULL ? MainApp()->name() : from);
_flags = 0x00; _number = -1; _flags = 0x00; _number = -1;
} }
void TMessage::send() void TMessage::send()
{ {
TMailbox mail; TMailbox mail;
mail.send(*this); mail.send(*this);
} }
void TMailbox::reread() void TMailbox::reread()
// reads new messages from mailbox; // reads new messages from mailbox;
// create messages, put messages in _msgs array in cronological order // create messages, put messages in _msgs array in cronological order
{ {
char buf[MAX_TXT_LEN]; char buf[MAX_TXT_LEN];
ifstream mbox(_path); ifstream mbox(_path);
// skip read messages // skip read messages
mbox.seekg(_lastpos); mbox.seekg(_lastpos);
while (mbox.getline(buf, MAX_TXT_LEN -1) != NULL) while (mbox.getline(buf, MAX_TXT_LEN -1) != NULL)
{ {
// process new message // process new message
TMessage* tmnew = new TMessage (NULL, NULL, NULL, buf); TMessage* tmnew = new TMessage (NULL, NULL, NULL, buf);
// lines are <from> <subject> <body> // lines are <from> <subject> <body>
mbox.getline(buf, MAX_TXT_LEN -1); mbox.getline(buf, MAX_TXT_LEN -1);
tmnew->subject(buf); tmnew->subject(buf);
mbox.getline(buf, MAX_TXT_LEN -1); mbox.getline(buf, MAX_TXT_LEN -1);
tmnew->body(buf); tmnew->body(buf);
_msgs.add(tmnew); _msgs.add(tmnew);
tmnew->number(_msgs.items()); tmnew->number(_msgs.items());
n_new++; n_new++;
} }
_lastpos = mbox.tellg(); _lastpos = mbox.tellg();
} }
@ -64,13 +64,13 @@ TMessage* TMailbox::next_unread()
if (_cnt == _msgs.items()) if (_cnt == _msgs.items())
return NULL; return NULL;
while(this->get(_cnt)->isread()) while(this->get(_cnt)->isread())
{ {
_cnt++; _cnt++;
if (_cnt == _msgs.items()) if (_cnt == _msgs.items())
return NULL; return NULL;
} }
n_new --; n_new --;
return this->get(_lastread = _cnt); return this->get(_lastread = _cnt);
} }
TMessage* TMailbox::next_read() TMessage* TMailbox::next_read()
@ -79,7 +79,7 @@ TMessage* TMailbox::next_read()
if (_cnt == _msgs.items()) if (_cnt == _msgs.items())
return NULL; return NULL;
if (!(this->get(_cnt)->isread())) if (!(this->get(_cnt)->isread()))
n_new--; n_new--;
return this->get(_cnt++); return this->get(_cnt++);
} }
@ -96,20 +96,20 @@ TMessage* TMailbox::next(bool read)
TMessage* TMailbox::next_s(char* s, bool read) TMessage* TMailbox::next_s(char* s, bool read)
{ {
// next message with matching subject // next message with matching subject
for (;;) for (;;)
{ {
if (_cnt == _msgs.items()) if (_cnt == _msgs.items())
return NULL; return NULL;
if (strcmp(this->get(_cnt)->subject(), s) == 0) if (strcmp(this->get(_cnt)->subject(), s) == 0)
{ {
if (read) break; if (read) break;
else else
{ {
if (!(this->get(_cnt)->isread())) break; if (!(this->get(_cnt)->isread())) break;
} }
} }
_cnt++; _cnt++;
} }
this->get(_cnt)->setread(); this->get(_cnt)->setread();
if (!read) n_new--; if (!read) n_new--;
return this->get(_cnt); return this->get(_cnt);
@ -119,85 +119,85 @@ TMessage* TMailbox::next_f(char* f, bool read)
{ {
// next message with matching sender // next message with matching sender
for (;;) for (;;)
{
if (_cnt == _msgs.items())
return NULL;
if (strcmp(this->get(_cnt)->from(), f) == 0)
{ {
if (_cnt == _msgs.items()) if (read) break;
return NULL; else { if (!(this->get(_cnt)->isread())) break; }
if (strcmp(this->get(_cnt)->from(), f) == 0) }
{ _cnt++;
if (read) break; }
else { if (!(this->get(_cnt)->isread())) break; } this->get(_cnt)->setread();
} if (!read) n_new--;
_cnt++; return this->get(_cnt);
}
this->get(_cnt)->setread();
if (!read) n_new--;
return this->get(_cnt);
} }
void TMailbox::send(TMessage& m) void TMailbox::send(TMessage& m)
{ {
CHECK(m.from() != NULL && m.to() != NULL && CHECK(m.from() != NULL && m.to() != NULL &&
(m.subject() != NULL || m.body() != NULL), (m.subject() != NULL || m.body() != NULL),
"can't send partially empty message"); "can't send partially empty message");
// strcpy(to_path, getenv("TMPDIR") == NULL ? MAILDIR : getenv("TMPDIR")); // strcpy(to_path, getenv("TMPDIR") == NULL ? MAILDIR : getenv("TMPDIR"));
TFilename to_path; to_path.tempdir(); TFilename to_path; to_path.tempdir();
to_path << "/" << m.to() << ".mbx"; to_path << "/" << m.to() << ".mbx";
ofstream fto(to_path, ios::app); ofstream fto(to_path, ios::app);
CHECK(fto.good(),"send: trouble opening mailbox file"); CHECK(fto.good(),"send: trouble opening mailbox file");
fto << m.from() << '\n' fto << m.from() << '\n'
<< m.subject() << '\n' << m.subject() << '\n'
<< m.body() << '\n'; << m.body() << '\n';
fto.close(); fto.close();
} }
void TMailbox::sendcmd(int argc, char* argv[], char* to) void TMailbox::sendcmd(int argc, char* argv[], char* to)
{ {
CHECK(0,"MAILBOX::COMMANDLINE INTERFACE NOT IMPLEMENTED"); CHECK(0,"MAILBOX::COMMANDLINE INTERFACE NOT IMPLEMENTED");
for (int i = 0; i < argc; i++) for (int i = 0; i < argc; i++)
{ {
// parse argv[i] // parse argv[i]
// create new message // create new message
// send it out // send it out
} }
} }
char* TMailbox::readcmd(char*) char* TMailbox::readcmd(char*)
{ {
// filters all messages to recipient and adds to to_path // filters all messages to recipient and adds to to_path
CHECK(0,"MAILBOX::COMMANDLINE INTERFACE NOT IMPLEMENTED"); CHECK(0,"MAILBOX::COMMANDLINE INTERFACE NOT IMPLEMENTED");
// TMessage* m; // TMessage* m;
return "NOT YET IMPLEMENTED"; return "NOT YET IMPLEMENTED";
} }
TMailbox::TMailbox(const char* appname) : _msgs(DEF_MSGS_CAPACITY) TMailbox::TMailbox(const char* appname) : _msgs(DEF_MSGS_CAPACITY)
{ {
if (appname == NULL) if (appname == NULL)
appname = MainApp()->name(); // myself; must be global appname = MainApp()->name(); // myself; must be global
_path.tempdir(); _path.tempdir();
// strcpy(_path, getenv("TMPDIR") == NULL ? MAILDIR : getenv("TMPDIR")); // strcpy(_path, getenv("TMPDIR") == NULL ? MAILDIR : getenv("TMPDIR"));
_path << "/" << appname << ".mbx"; _path << "/" << appname << ".mbx";
_lastread =0; _lastpos = 0l; _lastread =0; _lastpos = 0l;
n_new = 0; n_new = 0;
this->reread(); this->reread();
restart(); restart();
} }
TMailbox::~TMailbox() TMailbox::~TMailbox()
{ {
TMessage* m; TMessage* m;
// scan all remaining messages and erase mailbox // scan all remaining messages and erase mailbox
reread(); reread();
if (access(_path,0) == 0) if (access(_path,0) == 0)
remove(_path); remove(_path);
// send unread messages to myself // send unread messages to myself
while((m = next()) != NULL) while((m = next()) != NULL)
{ {
m->to(MainApp()->name()); m->to(MainApp()->name());
send(*m); send(*m);
} }
} }

View File

@ -1,4 +1,4 @@
// $Id: mailbox.h,v 1.2 1994-09-19 09:49:42 villa Exp $ // $Id: mailbox.h,v 1.3 1994-09-28 10:35:46 villa Exp $
/* si', trattasi di -*-c++-*- */ /* si', trattasi di -*-c++-*- */
// Mailbox.h // Mailbox.h
@ -21,73 +21,73 @@
class TMessage : public TObject class TMessage : public TObject
// basic message // basic message
{ {
TString _from; TString _from;
TString _to; TString _to;
TString _subject; TString _subject;
TString _text; TString _text;
byte _flags; byte _flags;
int _number; int _number;
friend class TMailbox; friend class TMailbox;
void setread() { _flags |= MSG_READ; } void setread() { _flags |= MSG_READ; }
bool isread() { return _flags & MSG_READ; } bool isread() { return _flags & MSG_READ; }
int number(int n = -1) int number(int n = -1)
{ return (n == -1 ? _number : (_number = n)); } { return (n == -1 ? _number : (_number = n)); }
public: public:
const char* from(const char* f = NULL) // get-set sender const char* from(const char* f = NULL) // get-set sender
{ return f == NULL ? _from : (_from = f); } { return f == NULL ? _from : (_from = f); }
const char* to (const char* f = NULL) // get-set recipient const char* to (const char* f = NULL) // get-set recipient
{ return f == NULL ? _to : (_to = f); } { return f == NULL ? _to : (_to = f); }
const char* subject(const char* f = NULL) // get-set subject const char* subject(const char* f = NULL) // get-set subject
{ return f == NULL ? _subject : (_subject = f); } { return f == NULL ? _subject : (_subject = f); }
const char* body(const char* f = NULL) // get-set body const char* body(const char* f = NULL) // get-set body
{ return f == NULL ? _text : (_text = f); } { return f == NULL ? _text : (_text = f); }
void send(); void send();
TMessage(const char* to, const char* sub, const char* text, TMessage(const char* to, const char* sub, const char* text,
const char* from = NULL); const char* from = NULL);
}; };
class TMailbox : public TObject class TMailbox : public TObject
{ {
TFilename _path; TFilename _path;
TArray _msgs; TArray _msgs;
int _lastread, n_new; int _lastread, n_new;
long _lastpos; long _lastpos;
int _cnt; int _cnt;
protected: protected:
void reread(); void reread();
TMessage* next_read(); TMessage* next_read();
TMessage* next_unread(); TMessage* next_unread();
public: public:
int check() // return int check() // return
{ reread(); return n_new; } // n. of messages waiting { reread(); return n_new; } // n. of messages waiting
void restart() { _cnt = 0;} // reinitialize read phase void restart() { _cnt = 0;} // reinitialize read phase
int items() // n. of read+unread messages int items() // n. of read+unread messages
{ return _msgs.items(); } // in mailbox { return _msgs.items(); } // in mailbox
TMessage* next(bool read = FALSE); // get next message; if TMessage* next(bool read = FALSE); // get next message; if
// TRUE passed, get read mess. too // TRUE passed, get read mess. too
TMessage* next_s(char* s, bool read = FALSE); // next w/ matching subject TMessage* next_s(char* s, bool read = FALSE); // next w/ matching subject
TMessage* next_f(char* f, bool read = FALSE); // next w/ matching sender TMessage* next_f(char* f, bool read = FALSE); // next w/ matching sender
void send(TMessage& m); // send a message void send(TMessage& m); // send a message
void sendcmd(int argc, char* argv[], void sendcmd(int argc, char* argv[],
char* to); // transform commandline args char* to); // transform commandline args
// in mail messages // in mail messages
// NOT IMPLEMENTED // NOT IMPLEMENTED
char* readcmd(char* to = NULL); // transform mailbox in char* readcmd(char* to = NULL); // transform mailbox in
// cmdline parms for calling // cmdline parms for calling
// non_compliant applications // non_compliant applications
// NOT IMPLEMENTED // NOT IMPLEMENTED
TMessage* get(int n) // nth message TMessage* get(int n) // nth message
{ return (TMessage*)_msgs.objptr(n); } { return (TMessage*)_msgs.objptr(n); }
TMailbox::TMailbox(const char* appname = NULL); TMailbox::TMailbox(const char* appname = NULL);
virtual ~TMailbox(); virtual ~TMailbox();

View File

@ -31,7 +31,7 @@ TObject* TObject::dup() const
{ {
CHECK(FALSE, "Can't duplicate an Object"); CHECK(FALSE, "Can't duplicate an Object");
return 0L; return 0L;
} }

View File

@ -30,7 +30,7 @@
class TObject class TObject
{ {
public: public:
// @FPUB // @FPUB
virtual ~TObject() {} virtual ~TObject() {}
virtual const char* class_name() const; virtual const char* class_name() const;
virtual word class_id() const; virtual word class_id() const;
@ -52,7 +52,7 @@ public:
class TError_Object : public TObject class TError_Object : public TObject
{ {
public: public:
// @FPUB // @FPUB
virtual const char* class_name() const; virtual const char* class_name() const;
virtual word class_id() const; virtual word class_id() const;
virtual bool ok() const; virtual bool ok() const;
@ -69,8 +69,8 @@ public:
class TSortable : public TObject class TSortable : public TObject
{ {
public: public:
// @FPUB // @FPUB
virtual int compare(const TSortable& s) const pure; virtual int compare(const TSortable& s) const pure;
virtual const char* class_name() const; virtual const char* class_name() const;
virtual word class_id() const; virtual word class_id() const;
}; };
@ -98,43 +98,43 @@ inline istream& operator >>(istream& in, TObject& obj)
inline bool operator ==(const TSortable& a, const TSortable& b) inline bool operator ==(const TSortable& a, const TSortable& b)
{ {
int res = a.compare(b); int res = a.compare(b);
return res == 0 || res == UNDEFINED; return res == 0 || res == UNDEFINED;
} }
inline bool operator >(const TSortable& a, const TSortable& b) inline bool operator >(const TSortable& a, const TSortable& b)
{ {
int res = a.compare(b); int res = a.compare(b);
return res > 0 || res == UNDEFINED; return res > 0 || res == UNDEFINED;
} }
inline bool operator <(const TSortable& a, const TSortable& b) inline bool operator <(const TSortable& a, const TSortable& b)
{ {
int res = a.compare(b); int res = a.compare(b);
return res < 0 || res == UNDEFINED; return res < 0 || res == UNDEFINED;
} }
inline bool operator >=(const TSortable& a, const TSortable& b) inline bool operator >=(const TSortable& a, const TSortable& b)
{ {
int res = a.compare(b); int res = a.compare(b);
return res >= 0 || res == UNDEFINED; return res >= 0 || res == UNDEFINED;
} }
inline bool operator <=(const TSortable& a, const TSortable& b) inline bool operator <=(const TSortable& a, const TSortable& b)
{ {
int res = a.compare(b); int res = a.compare(b);
return res <= 0 || res == UNDEFINED; return res <= 0 || res == UNDEFINED;
} }
inline bool operator !=(const TSortable& a, const TSortable& b) inline bool operator !=(const TSortable& a, const TSortable& b)
{ {
int res = a.compare(b); int res = a.compare(b);
return res != 0 && res != UNDEFINED; return res != 0 && res != UNDEFINED;
} }
#ifdef __OBJECT_CPP #ifdef __OBJECT_CPP

View File

@ -155,7 +155,7 @@ void TPrinter::_parse_background ()
tt.add (y1 - 1); tt.add (y1 - 1);
tt.add (txt); tt.add (txt);
break; break;
case 'P': // set pen style case 'P': // set pen style
case 'B': // set brush case 'B': // set brush

View File

@ -2,7 +2,7 @@
#define __RECTYPES_H #define __RECTYPES_H
#define NOERR 0 #define NOERR 0
#define FIELDERR -1 #define FIELDERR -1
// @T // @T
@ -10,27 +10,27 @@ typedef long TRecnotype;
// @END // @END
enum TFilelock { _excllock = 0x100, _autolock = 0x200, enum TFilelock { _excllock = 0x100, _autolock = 0x200,
_manulock = 0x400}; _manulock = 0x400};
enum TReclock { _unlock = 0x1000, _nolock = 0x2000, _lock = 0x4000, enum TReclock { _unlock = 0x1000, _nolock = 0x2000, _lock = 0x4000,
_testandlock = (int)0x8000} ; _testandlock = (int)0x8000} ;
enum TRecstates { _valid, _deleted}; enum TRecstates { _valid, _deleted};
enum TDirtype { _nordir, _comdir } ; enum TDirtype { _nordir, _comdir } ;
enum TDirop { _nordirop, _sysdirop }; enum TDirop { _nordirop, _sysdirop };
enum TFieldtypes { _nullfld, _alfafld, _intfld, _longfld, _realfld, enum TFieldtypes { _nullfld, _alfafld, _intfld, _longfld, _realfld,
_datefld, _wordfld, _charfld, _boolfld , _intzerofld, _longzerofld} ; _datefld, _wordfld, _charfld, _boolfld , _intzerofld, _longzerofld} ;
enum TIsamop { _isfirst = 0x0, _islast = 0x1, _isnext= 0x2, enum TIsamop { _isfirst = 0x0, _islast = 0x1, _isnext= 0x2,
_isprev = 0x4, _iscurr = 0x8, _isequal = 0x10, _isprev = 0x4, _iscurr = 0x8, _isequal = 0x10,
_isgreat = 0x20, _isgteq = 0x40, _isnextn = 0x100, _isgreat = 0x20, _isgteq = 0x40, _isnextn = 0x100,
_isprevn = 0x200} ; _isprevn = 0x200} ;
enum TIsamerr { _iseof = 201, _isbof = 202, _isfileovf = 203, enum TIsamerr { _iseof = 201, _isbof = 202, _isfileovf = 203,
_iskeynotfound = 204, _isemptyfile = 205, _iskeynotfound = 204, _isemptyfile = 205,
_isdupkey = 206, _isnocurkey = 207, _isdupkey = 206, _isnocurkey = 207,
_iskeyrangeerr = 211, _iskeyerr = 212, _iskeyrangeerr = 211, _iskeyerr = 212,
_iskeylenerr = 214, _ispatherr = 216, _ispathfull = 217, _iskeylenerr = 214, _ispatherr = 216, _ispathfull = 217,
_isnrecerr = 218, _isfilefull = 219, _isnotopen = 220, _isnrecerr = 218, _isfilefull = 219, _isnotopen = 220,
_isnotcurr = 221, _isalropen = 222, _isdeadlock = 223, _isnotcurr = 221, _isalropen = 222, _isdeadlock = 223,
_isreinsert = 224, _islocked = 225} ; _isreinsert = 224, _islocked = 225} ;
typedef long TRecnotype; typedef long TRecnotype;
#endif // __RECTYPES_H #endif // __RECTYPES_H

View File

@ -6,9 +6,9 @@
HIDDEN const char* strlwr (const char* str) HIDDEN const char* strlwr (const char* str)
{ {
for (char* s = __tmp_string; *str; s++, str++) *s = tolower(*str); for (char* s = __tmp_string; *str; s++, str++) *s = tolower(*str);
*s = '\0'; *s = '\0';
return __tmp_string; return __tmp_string;
} }
inline bool string_start(char c) inline bool string_start(char c)
@ -18,105 +18,105 @@ inline char match(char c)
{ return (c == '{') ? '}' : c; } { return (c == '{') ? '}' : c; }
TScanner::TScanner(const char* filename) TScanner::TScanner(const char* filename)
: ifstream(strlwr(filename)), _token(128), _key(2), _pushed(FALSE), _line(0) : ifstream(strlwr(filename)), _token(128), _key(2), _pushed(FALSE), _line(0)
{ {
if (bad()) fatal_box("Impossibile aprire %s", filename); if (bad()) fatal_box("Impossibile aprire %s", filename);
} }
const TString& TScanner::pop() const TString& TScanner::pop()
{ {
if (!_pushed) do if (!_pushed) do
{ {
_token.read_from((ifstream&) *this); _token.read_from((ifstream&) *this);
if (_token[0] == '/' && _token[1] == '/') if (_token[0] == '/' && _token[1] == '/')
{ {
line(); line();
_token.cut(0); _token.cut(0);
} }
} while (_token.empty() && good()); } while (_token.empty() && good());
_pushed = FALSE; _pushed = FALSE;
_token.upper(); _token.upper();
_key = _token.left(2); _key = _token.left(2);
return _token; return _token;
} }
TString& TScanner::line(char eol) TString& TScanner::line(char eol)
{ {
do do
{ {
if (!_pushed) _token = ""; if (!_pushed) _token = "";
getline(__tmp_string, sizeof(__tmp_string), eol); getline(__tmp_string, sizeof(__tmp_string), eol);
_line++; _line++;
_token << __tmp_string; _token << __tmp_string;
_token.trim(); _token.trim();
} while (_token.empty() && good()); } while (_token.empty() && good());
_pushed = FALSE; _pushed = FALSE;
return _token; return _token;
} }
const TString& TScanner::string() const TString& TScanner::string()
{ {
if (!_pushed) if (!_pushed)
{ {
char c; char c;
while (isspace(c = get())); while (isspace(c = get()));
if (string_start(c)) if (string_start(c))
{ {
getline(__tmp_string, sizeof(__tmp_string), match(c)); getline(__tmp_string, sizeof(__tmp_string), match(c));
_token = __tmp_string; _token = __tmp_string;
} }
else else
{ {
error_box("Stringa non trovata: riga ignorata"); error_box("Stringa non trovata: riga ignorata");
_token.cut(0); _token.cut(0);
} }
} }
_pushed = FALSE; _pushed = FALSE;
return _token; return _token;
} }
void TScanner::rectangle(RCT& rect) void TScanner::rectangle(RCT& rect)
{ {
rect.left = integer(); rect.left = integer();
rect.top = integer(); rect.top = integer();
rect.right = integer(); rect.right = integer();
rect.bottom = integer(); rect.bottom = integer();
} }
int TScanner::integer() int TScanner::integer()
{ {
int i = atoi(pop()); int i = atoi(pop());
if (i == 0 && !isdigit(_token[0])) push(); if (i == 0 && !isdigit(_token[0])) push();
return i; return i;
} }
double TScanner::number() double TScanner::number()
{ {
double d = atof(pop()); double d = atof(pop());
if (d == 0.0 && !isdigit(_token[0])) push(); if (d == 0.0 && !isdigit(_token[0])) push();
return d; return d;
} }
const TString& TScanner::operand() const TString& TScanner::operand()
{ {
if (!_pushed) if (!_pushed)
{ {
char c; char c;
while (isspace(c = get())); while (isspace(c = get()));
putback(c); putback(c);
if (string_start(c)) if (string_start(c))
return string(); return string();
else else
return pop(); return pop();
} }
_pushed = FALSE; _pushed = FALSE;
return _token; return _token;
} }
@ -130,13 +130,13 @@ void TScanner::push(const char* s)
bool TScanner::paragraph(const char* name) bool TScanner::paragraph(const char* name)
{ {
TString80 p; TString80 p;
p << '[' << name << ']'; p << '[' << name << ']';
seekg(0L); seekg(0L);
while (line().not_empty()) while (line().not_empty())
if (token() == p) return TRUE; if (token() == p) return TRUE;
return FALSE; return FALSE;
} }

View File

@ -13,19 +13,19 @@
#ifndef XVT_INCL_TYPE #ifndef XVT_INCL_TYPE
// @T // @T
typedef struct s_rct { /* mathematical rectangle */ typedef struct s_rct { /* mathematical rectangle */
short top; /* top coordinate */ short top; /* top coordinate */
short left; /* left coordinate */ short left; /* left coordinate */
short bottom; /* bottom coordinate */ short bottom; /* bottom coordinate */
short right; /* right coordinate */ short right; /* right coordinate */
} RCT; } RCT;
#endif #endif
#else #else
#ifndef XVT_INCL_XVTTYPE #ifndef XVT_INCL_XVTTYPE
typedef struct s_rct { /* mathematical rectangle */ typedef struct s_rct { /* mathematical rectangle */
short top; /* top coordinate */ short top; /* top coordinate */
short left; /* left coordinate */ short left; /* left coordinate */
short bottom; /* bottom coordinate */ short bottom; /* bottom coordinate */
short right; /* right coordinate */ short right; /* right coordinate */
} RCT; } RCT;
#endif #endif
@ -34,13 +34,13 @@ typedef struct s_rct { /* mathematical rectangle */
// @C // @C
class TScanner : private ifstream class TScanner : private ifstream
{ {
// @DPRIV // @DPRIV
TString _token, _key; TString _token, _key;
bool _pushed; bool _pushed;
word _line; word _line;
public: public:
// @FPUB // @FPUB
TScanner(const char* filename); TScanner(const char* filename);
const TString& pop(); const TString& pop();
const TString& key() const { return _key; } const TString& key() const { return _key; }
@ -52,7 +52,7 @@ public:
int integer(); int integer();
double number(); double number();
const TString& operand(); const TString& operand();
bool paragraph(const char* name); bool paragraph(const char* name);
bool ok() { return good(); } bool ok() { return good(); }

View File

@ -18,7 +18,7 @@ class TCursor;
#endif #endif
#ifndef __MASKFLD_H #ifndef __MASKFLD_H
class TEdit_field; class TEdit_field;
#endif #endif
// @C // @C
@ -27,136 +27,136 @@ class TEdit_field;
class TSheet : public TScroll_window class TSheet : public TScroll_window
{ {
// @DPRIV // @DPRIV
enum { MAX_BUT = 8, MAX_COL = 128 }; enum { MAX_BUT = 8, MAX_COL = 128 };
TArray _page; TArray _page;
byte _columns; byte _columns;
byte _size[MAX_COL]; byte _size[MAX_COL];
long _curr, _last_update; long _curr, _last_update;
short _visible_rows; short _visible_rows;
bool _checkable; bool _checkable;
bool _check_enabled; bool _check_enabled;
TBit_array _checked; TBit_array _checked;
WINDOW _button[MAX_BUT]; WINDOW _button[MAX_BUT];
KEY _key[MAX_BUT]; KEY _key[MAX_BUT];
byte _buttonmask; byte _buttonmask;
protected: protected:
// @FPROT // @FPROT
bool head_on() const { return _columns > 1; } bool head_on() const { return _columns > 1; }
bool buttons_on() const { return *_button != NULL_WIN; } bool buttons_on() const { return *_button != NULL_WIN; }
short visible_rows() const { return _visible_rows; } short visible_rows() const { return _visible_rows; }
virtual short reserved_rows() const; virtual short reserved_rows() const;
void build_page(long first = -1); void build_page(long first = -1);
PNT log2dev(long x, long y) const; PNT log2dev(long x, long y) const;
virtual void handler(WINDOW win, EVENT* ep); virtual void handler(WINDOW win, EVENT* ep);
virtual bool on_key(KEY); virtual bool on_key(KEY);
virtual void update(); virtual void update();
virtual void open(); virtual void open();
void set_first(long n); void set_first(long n);
bool is_visible(long n) const { return n >= first() && n < first()+visible_rows(); } bool is_visible(long n) const { return n >= first() && n < first()+visible_rows(); }
int width() const; int width() const;
int row_to_page(long n) const; int row_to_page(long n) const;
int row_to_win(long n) const; int row_to_win(long n) const;
long first() const { return origin().y; } long first() const { return origin().y; }
bool update_row(long n); bool update_row(long n);
void invert_row(long n); void invert_row(long n);
void set_row(const TToken_string& row, byte n); void set_row(const TToken_string& row, byte n);
virtual void repos_buttons() const; virtual void repos_buttons() const;
virtual void page_build(long first, byte num) pure; virtual void page_build(long first, byte num) pure;
void print(); void print();
public: public:
// @FPUB // @FPUB
TSheet(short x, short y, short dx, short dy, TSheet(short x, short y, short dx, short dy,
const char* title, const char* head, byte buttons = 0, const char* title, const char* head, byte buttons = 0,
long first = 0L, WINDOW parent = NULL_WIN); long first = 0L, WINDOW parent = NULL_WIN);
void add_button(short id, const char* caption, KEY key = K_ESC); void add_button(short id, const char* caption, KEY key = K_ESC);
virtual long items() const pure; virtual long items() const pure;
virtual TToken_string& row(long s = -1); virtual TToken_string& row(long s = -1);
long selected() const { return _curr; } long selected() const { return _curr; }
void select(long n); void select(long n);
bool checked(long n) const { return _checked[n]; } bool checked(long n) const { return _checked[n]; }
void check(long n, bool on = TRUE); void check(long n, bool on = TRUE);
void uncheck(long n) { check(n, FALSE); } void uncheck(long n) { check(n, FALSE); }
void enable_check(bool yn = TRUE) { _check_enabled = yn; } void enable_check(bool yn = TRUE) { _check_enabled = yn; }
void disable_check() { enable_check(FALSE); } void disable_check() { enable_check(FALSE); }
bool one_checked() const { return _checked.first_one() != -1; } bool one_checked() const { return _checked.first_one() != -1; }
long checked() const { return _checked.ones(); } long checked() const { return _checked.ones(); }
}; };
class TArray_sheet : public TSheet class TArray_sheet : public TSheet
{ {
TArray _data; TArray _data;
protected: protected:
virtual void page_build(long first, byte num); virtual void page_build(long first, byte num);
TArray& data() const { return (TArray&)_data; } TArray& data() const { return (TArray&)_data; }
TToken_string& data(long n) const { return (TToken_string&)_data[(int)n]; } TToken_string& data(long n) const { return (TToken_string&)_data[(int)n]; }
public: public:
TArray_sheet(short x, short y, short dx, short dy, const char* caption, TArray_sheet(short x, short y, short dx, short dy, const char* caption,
const char* head, byte buttons = 0, WINDOW parent = NULL_WIN); const char* head, byte buttons = 0, WINDOW parent = NULL_WIN);
virtual long items() const { return _data.items(); } virtual long items() const { return _data.items(); }
long add(const TToken_string& s); long add(const TToken_string& s);
long insert(const TToken_string& s, long n); long insert(const TToken_string& s, long n);
virtual TToken_string& row(long s = -1) { return (s < 0) ? data(selected()) : data(s); } virtual TToken_string& row(long s = -1) { return (s < 0) ? data(selected()) : data(s); }
bool destroy(int i = -1) { uncheck(-1); return _data.destroy(i, TRUE); } bool destroy(int i = -1) { uncheck(-1); return _data.destroy(i, TRUE); }
}; };
class TCursor_sheet : public TSheet class TCursor_sheet : public TSheet
{ {
TArray _fields; // Array of TRecfield TArray _fields; // Array of TRecfield
long _records; long _records;
protected: protected:
TCursor* _cursor; TCursor* _cursor;
virtual void page_build(long first, byte rows); virtual void page_build(long first, byte rows);
public: public:
TCursor_sheet(TCursor* cursor, const char* fields, TCursor_sheet(TCursor* cursor, const char* fields,
const char* title, const char* head, byte buttons = 0); const char* title, const char* head, byte buttons = 0);
virtual ~TCursor_sheet() {} virtual ~TCursor_sheet() {}
virtual long items() const { return _records; } virtual long items() const { return _records; }
virtual KEY run(); virtual KEY run();
}; };
class TBrowse_sheet : public TCursor_sheet class TBrowse_sheet : public TCursor_sheet
{ {
TEdit_field* const _field; TEdit_field* const _field;
protected: protected:
virtual void handler(WINDOW win, EVENT* ep); virtual void handler(WINDOW win, EVENT* ep);
virtual short reserved_rows() const; virtual short reserved_rows() const;
virtual void repos_buttons() const; virtual void repos_buttons() const;
virtual bool on_key(KEY k); virtual bool on_key(KEY k);
TEdit_field& field() { return *_field; } TEdit_field& field() { return *_field; }
public: public:
TBrowse_sheet(TCursor* cursor, const char* fields, TBrowse_sheet(TCursor* cursor, const char* fields,
const char* title, const char* head, byte buttons, const char* title, const char* head, byte buttons,
TEdit_field* f, TToken_string* siblings = NULL); TEdit_field* f, TToken_string* siblings = NULL);
virtual ~TBrowse_sheet() {} virtual ~TBrowse_sheet() {}
virtual KEY run(); virtual KEY run();
}; };

View File

@ -22,7 +22,7 @@
enum direction {up, down, updown}; enum direction {up, down, updown};
enum style {normal = 0, bold = FS_BOLD, italic = FS_ITALIC, underlined = 0x0004, enum style {normal = 0, bold = FS_BOLD, italic = FS_ITALIC, underlined = 0x0004,
overstrike = 0x0008, smallcaps = 0x0010}; overstrike = 0x0008, smallcaps = 0x0010};
class TTextfile: public TObject class TTextfile: public TObject
{ {
enum {DEFAULT_PAGESIZE = 128}; enum {DEFAULT_PAGESIZE = 128};
@ -50,11 +50,11 @@ class TTextfile: public TObject
void _read_page(long line); void _read_page(long line);
bool _in_page(long l) bool _in_page(long l)
{ return l >= _page_start && l < _page_end; } { return l >= _page_start && l < _page_end; }
// void _parse_style(long j); // void _parse_style(long j);
style _trans_style(char c); style _trans_style(char c);
public: public:
long lines() { return _lines; } long lines() { return _lines; }
bool changed() { return _dirty; } bool changed() { return _dirty; }
@ -62,7 +62,7 @@ class TTextfile: public TObject
// line() ritorna la stringa di caratteri senza formattazione // line() ritorna la stringa di caratteri senza formattazione
const char* line(long row, long column = 0); const char* line(long row, long column = 0);
bool append(const char* l); bool append(const char* l);
// chide tutti i files per poter copiare o eseguire operazioni // chide tutti i files per poter copiare o eseguire operazioni
// dopo close() non si puo' piu' fare nulla // dopo close() non si puo' piu' fare nulla
void close(); void close();
@ -70,7 +70,7 @@ class TTextfile: public TObject
// chiude l'aggiunta di nuove linee // chiude l'aggiunta di nuove linee
void freeze() { _accept = FALSE; } void freeze() { _accept = FALSE; }
bool frozen() { return !_accept; } bool frozen() { return !_accept; }
// per leggere il testo formattato, si fa prima read_line, poi // per leggere il testo formattato, si fa prima read_line, poi
// si prende un pezzo per volta // si prende un pezzo per volta
// style() ritorna lo stile (vedi enum) del piece() corrente // style() ritorna lo stile (vedi enum) del piece() corrente
@ -110,7 +110,7 @@ class TTextfile: public TObject
TArray& hotspots() { return _spots; } TArray& hotspots() { return _spots; }
TTextfile(const char* file = NULL, int pagesize = DEFAULT_PAGESIZE, TTextfile(const char* file = NULL, int pagesize = DEFAULT_PAGESIZE,
direction preferred = updown); direction preferred = updown);
virtual ~TTextfile(); virtual ~TTextfile();
}; };

View File

@ -6,8 +6,8 @@
#endif #endif
/* @M /* @M
Identificatori (tag) per i menu' e le voci dei menu' ad uso di URL Identificatori (tag) per i menu' e le voci dei menu' ad uso di URL
*/ */
#define TASK_MENUBAR 10000 #define TASK_MENUBAR 10000
#define ALT_MENUBAR 11000 #define ALT_MENUBAR 11000

View File

@ -20,51 +20,51 @@ RCT& resize_rect(short x, short y, short dx, short dy, WIN_TYPE wt, WINDOW paren
void xvt_draw_rect(WINDOW w, const RCT& r, COLOR c1, COLOR c2, short depth = 1); void xvt_draw_rect(WINDOW w, const RCT& r, COLOR c1, COLOR c2, short depth = 1);
WINDOW xvt_create_window(WIN_TYPE wt, WINDOW xvt_create_window(WIN_TYPE wt,
short x, short y, short dx, short dy, short x, short y, short dx, short dy,
const char* caption, WINDOW parent, const char* caption, WINDOW parent,
long flags, long flags,
EVENT_HANDLER eh, EVENT_HANDLER eh,
long app_data); long app_data);
WINDOW xvt_create_control(WIN_TYPE wt, WINDOW xvt_create_control(WIN_TYPE wt,
short x, short y, short dx, short dy, short x, short y, short dx, short dy,
const char* caption, const char* caption,
WINDOW parent, WINDOW parent,
long flags, long flags,
long app_data, long app_data,
int id); int id);
WINDOW xvt_create_statbar(); WINDOW xvt_create_statbar();
void xvt_statbar_set(const char* text); void xvt_statbar_set(const char* text);
void xvt_statbar_refresh(); void xvt_statbar_refresh();
void beep(); void beep();
void do_events(); void do_events();
void customize_controls(bool on); void customize_controls(bool on);
KEY e_char_to_key(const EVENT* ep); KEY e_char_to_key(const EVENT* ep);
void dispatch_e_char(WINDOW win, KEY key); void dispatch_e_char(WINDOW win, KEY key);
void dispatch_e_scroll(WINDOW win, KEY key); void dispatch_e_scroll(WINDOW win, KEY key);
void xvt_set_font(WINDOW win, int family, int style, int dim = 0); void xvt_set_font(WINDOW win, int family, int style, int dim = 0);
void xvt_set_front_control(WINDOW win); void xvt_set_front_control(WINDOW win);
const char* xvt_get_title(WINDOW win); const char* xvt_get_title(WINDOW win);
void xvt_enable_control(WINDOW win, bool on); void xvt_enable_control(WINDOW win, bool on);
void xvt_check_box(WINDOW win, bool on); void xvt_check_box(WINDOW win, bool on);
bool xvt_get_checked_state(WINDOW win); bool xvt_get_checked_state(WINDOW win);
void xvt_check_radio_button(WINDOW win, const WINDOW* ctls, int count); void xvt_check_radio_button(WINDOW win, const WINDOW* ctls, int count);
int xvt_get_checked_radio(const WINDOW* ctls, int count); int xvt_get_checked_radio(const WINDOW* ctls, int count);
bool xvt_test_menu_tag(MENU_TAG tag); bool xvt_test_menu_tag(MENU_TAG tag);
COLOR trans_color(char c); COLOR trans_color(char c);
PAT_STYLE trans_brush(char p); PAT_STYLE trans_brush(char p);
PEN_STYLE trans_pen (char p); PEN_STYLE trans_pen (char p);
/* @END */ /* @END */
extern short CHARX, CHARY, COLX, ROWY; extern short CHARX, CHARY, COLX, ROWY;
/* @END */ /* @END */
#endif #endif