Aggiunto gestore di errori di xvt

MOdificati leggermente i TRectype per quanto riguarda l'accesso ai files
Aggiunta la classe TRecord_array (fichissima)


git-svn-id: svn://10.65.10.50/trunk@1225 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1995-04-10 15:28:03 +00:00
parent 5ef3de0323
commit 6b47725702
22 changed files with 1455 additions and 1270 deletions

View File

@ -394,9 +394,10 @@ void TApplication::check_parameters(int & argc, char* argv[])
void TApplication::run(int argc, char* argv[], const char* title)
{
TFilename base(argv[0]);
base.ext(""); base.lower();
_title = title;
if (user().empty())
check_parameters(argc, argv);
@ -404,7 +405,7 @@ void TApplication::run(int argc, char* argv[], const char* title)
__argv = (const char**)argv;
int addbar = 0;
if (argc > 1)
if (argc > 1 && argv[1][0] == '-')
{
addbar = atoi(argv[1]+1);
_name = cmd2name(argv[0], argv[1]);

View File

@ -213,7 +213,7 @@ void TArray::pack()
}
HIDDEN int sortable_compare(const TObject** o1, const TObject** o2)
static int sortable_compare(const TObject** o1, const TObject** o2)
{
const TSortable* s1 = (const TSortable*)*o1;
const TSortable* s2 = (const TSortable*)*o2;

View File

@ -11,13 +11,13 @@ class THash_object : public TObject
TString _key;
TObject* _obj;
public:
TString& key() { return _key; }
TObject& obj() { return *_obj; }
THash_object(const char* k)
{ _key = k; }
THash_object(const char* k) : _key(k) {}
~THash_object() { if (_obj != NULL) delete _obj; }
};
@ -29,14 +29,14 @@ class TAssoc_array : public TObject
word _row;
word _col;
TArray _data[HASH_SIZE];
protected:
THash_object* _lookup(const char* k, bool& isnew, bool insert = FALSE);
public:
int items() const { return _cnt; }
void destroy();
virtual void destroy();
// aggiunge oggetto; Se c'era gia' la chiave guarda force:
// se force = TRUE lo sostituisce e ritorna TRUE

File diff suppressed because it is too large Load Diff

View File

@ -1380,7 +1380,8 @@ Se si utilizza spiegarne dettagliatamente il motivo.
}
return(-1);
}
/*
@($) prefname FILES
@ -1393,12 +1394,15 @@ s,s1 = stringhe di lavoro.
Versione DOS e XENIX.
@(FSV)
*/
*/
#ifndef FOXPRO
char *prefname()
{
static PathSt s;
#ifdef DOS
#ifdef DOS
char *s1 = getenv("PREFPATH");
if (s1 == NULL) s1 = "prefix.txt";
strcpy(s, s1);
@ -1407,6 +1411,8 @@ Versione DOS e XENIX.
#endif
return(s) ;
}
#endif
/*
@(#) CGetPref FILES

View File

@ -2,16 +2,11 @@
#include <stdio.h>
#include <stdlib.h>
#ifdef FOXPRO
#undef XVT
#include <windows.h>
#include <pro_ext.h>
#endif
#ifdef XVT
#ifndef XVT_INCL_XVT
#include <xvt.h>
#endif
#if XVT_OS == XVT_OS_WIN
#include <windows.h>
#include <keys.h>
@ -26,7 +21,7 @@
#define buildmsg() char msg[256];va_list argptr;va_start(argptr,fmt);vsprintf(msg,fmt,argptr);va_end(argptr)
#ifdef XVT_OS
#ifndef FOXPRO
int fatal_box(const char* fmt, ...)
{
@ -185,22 +180,24 @@ int __trace(const char* fmt, ...)
return f != NULL;
}
#endif // XVT_OS
#else // FOXPRO
#ifdef FOXPRO
#include <windows.h>
#include <pro_ext.h>
int error_box(const char* fmt, ...)
{
buildmsg();
MessageBeep(MB_ICONEXCLAMATION);
_UserError(msg);
return 0;
}
int fatal_box(const char* fmt, ...)
{
MessageBeep(MB_ICONHAND);
buildmsg();
MessageBeep(MB_ICONHAND);
MessageBox(GetFocus(), msg, "ERRORE FATALE", MB_OK | MB_ICONHAND | MB_SYSTEMMODAL);
_UserError(msg);
return 0;
}
@ -208,6 +205,7 @@ int fatal_box(const char* fmt, ...)
int message_box(const char* fmt, ...)
{
buildmsg();
MessageBeep(MB_ICONINFORMATION);
_UserError(msg);
return 0;
}
@ -215,6 +213,8 @@ int message_box(const char* fmt, ...)
int yesnofatal_box(const char* fmt, ...)
{
buildmsg();
MessageBeep(MB_ICONHAND);
MessageBox(GetFocus(), msg, "ERRORE FATALE", MB_OK | MB_ICONHAND | MB_SYSTEMMODAL);
_UserError(msg);
return 0;
}

View File

@ -715,7 +715,7 @@ wrec = buffer di lavoro.
}
}
IRecallRec(record);
if (test_share() && isfd->f.LockMode != ExclLock)
if (/* test_share() && */ isfd->f.LockMode != ExclLock)
{
RecType wrec = malloc(isfd->d->LenR);
memcpy(wrec, record, isfd->d->LenR);
@ -740,7 +740,7 @@ wrec = buffer di lavoro.
isfd->RecNo = (++isfd->d->EOD);
if ((isfd->r->NKeys) && IndActive)
{
if(test_share() && isfd->f.LockMode != ExclLock)
if(/* test_share() && */ isfd->f.LockMode != ExclLock)
CBLockFile(&isfd->i,err) ;
if (!addkeys(isfd, record, knum, err))
{
@ -759,7 +759,7 @@ wrec = buffer di lavoro.
{
CCloseFile(isfd->ln,isfd->d, isfd->ft) ;
}
if(test_share() && isfd->f.LockMode != ExclLock)
if(/* test_share() && */ isfd->f.LockMode != ExclLock)
CBUnLockFile(&isfd->i, &werr) ;
}
else
@ -777,13 +777,13 @@ wrec = buffer di lavoro.
}
if (isfd->ln > 0)
CCloseDir(isfd->ft);
if (test_share())
// if (test_share())
{
junk = cisunlock(isfd, &junk);
if (isstate == NOTRANS)
CLockRec(&isfd->f,isfd->RecNo,UnLock);
if (DEADLOCK(*err)) *err = IsDeadLock;
}
}
return(*err);
}
@ -885,7 +885,7 @@ key1,key = valori chiave.
}
if ((isfd->r->NKeys) && IndActive)
{
if(test_share() && isfd->f.LockMode != ExclLock)
if( /* test_share() && */ isfd->f.LockMode != ExclLock)
CBLockFile(&isfd->i,err) ;
delkeys(isfd, record, knum, err) ;
}
@ -908,17 +908,17 @@ key1,key = valori chiave.
}
else writeundo(FNDELETE, isfd, NULL);
}
if (test_share() && (isfd->r->NKeys) && IndActive &&
if (/* test_share() && */(isfd->r->NKeys) && IndActive &&
(isfd->f.LockMode != ExclLock))
CBUnLockFile(&isfd->i, &werr) ;
#else
if (test_share())
/* if (test_share()) */
{
CRead(&isfd->f,record,isfd->RecNo,UnLock);
if (isfd->r->NKeys && IndActive &&
(isfd->f.LockMode != ExclLock))
CBUnLockFile(&isfd->i, &werr) ;
}
}
#endif
return(*err);
}
@ -1046,10 +1046,10 @@ Utilizza la chiave 1 per ritrovare il record da aggiornare.
}
if ((isfd->r->NKeys) && IndActive)
{
if(test_share() && isfd->f.LockMode != ExclLock)
if(/* test_share() && */ isfd->f.LockMode != ExclLock)
CBLockFile(&isfd->i, err) ;
replkeys(isfd, oldrec, record, knum, err) ;
if(test_share() && isfd->f.LockMode != ExclLock)
if(/* test_share() && */ isfd->f.LockMode != ExclLock)
CBUnLockFile(&isfd->i, &werr) ;
}
CWrite(&isfd->f,record,isfd->RecNo,NoLock);
@ -1071,7 +1071,7 @@ Utilizza la chiave 1 per ritrovare il record da aggiornare.
}
#else
if (test_share())
// if (test_share())
CLockRec(&isfd->f,isfd->RecNo,UnLock);
#endif
free(oldrec);
@ -1188,17 +1188,17 @@ oldrec = buffer di lavoro.
if (memcmp(oldrec,record,isfd->d->LenR) == 0)
{
*err = NoErr;
if (test_share())
// if (test_share())
CLockRec(&isfd->f,isfd->RecNo,UnLock);
free(oldrec);
return(*err);
}
if ((isfd->r->NKeys) && IndActive)
{
if (test_share() && isfd->f.LockMode != ExclLock)
if (/* test_share() && */ isfd->f.LockMode != ExclLock)
CBLockFile(&isfd->i, err) ;
replkeys(isfd, oldrec, record, knum, err) ;
if (test_share() && isfd->f.LockMode != ExclLock)
if (/* test_share() && */ isfd->f.LockMode != ExclLock)
CBUnLockFile(&isfd->i, &werr) ;
}
if (isstate == NOTRANS) CWrite(&isfd->f,record,isfd->RecNo,UnLock);
@ -1219,7 +1219,7 @@ oldrec = buffer di lavoro.
else writeundo(FNREWRITE, isfd, oldrec);
}
#else
if (test_share())
/* if (test_share()) */
CLockRec(&isfd->f,isfd->RecNo,UnLock);
#endif
free(oldrec);
@ -1264,7 +1264,7 @@ key1 = valore della chiave.
}
if ((isfd->r->NKeys) && IndActive)
{
if(test_share() && isfd->f.LockMode != ExclLock)
if(/* test_share() && */ isfd->f.LockMode != ExclLock)
CBLockFile(&isfd->i, err) ;
delkeys(isfd, oldrec, knum, err);
}
@ -1286,16 +1286,16 @@ key1 = valore della chiave.
}
else writeundo(FNDELETE, isfd, NULL);
}
if (test_share() && (isfd->r->NKeys) && IndActive && (isfd->f.LockMode != ExclLock))
if (/* test_share() && */(isfd->r->NKeys) && IndActive && (isfd->f.LockMode != ExclLock))
CBUnLockFile(&isfd->i, &werr) ;
#else
if (test_share())
// if (test_share())
{
CLockRec(&isfd->f,isfd->RecNo,UnLock);
if (isfd->r->NKeys && IndActive &&
(isfd->f.LockMode != ExclLock))
CBUnLockFile(&isfd->i, &werr) ;
}
}
#endif
free(oldrec);
isfd->RecNo = 0;
@ -1342,7 +1342,7 @@ junk = variabile spazzatura per la chiamata di sleep.
}
} while (TESTLOCK(*err)) ;
#endif
if(test_share() && isfd->f.LockMode != ExclLock)
if(/* test_share() && */ isfd->f.LockMode != ExclLock)
CBLockFile(&isfd->i,err);
return(*err);
}
@ -1376,7 +1376,7 @@ Sblocca un file ISAM.
if (lockf(isfd->f.F,F_ULOCK,0L) == -1) *err = CIOResult() ;
} while (TESTLOCK(*err)) ;
#endif
if(test_share() && isfd->f.LockMode != ExclLock)
if(/* test_share() && */ isfd->f.LockMode != ExclLock)
CBUnLockFile(&isfd->i,err);
return(*err);
}

View File

@ -600,10 +600,12 @@ TPush_button::TPush_button(short left, short top, short right, short bottom,
_dx = (width - _picup->width()) >> 1;
_dy = (height - _picup->height()) >> 1;
_picup->set_pos(_dx, _dy);
if (_picdn)
_picdn->set_pos(_dx+DEPTH, _dy+DEPTH);
/*
_picup->set_pos(_dx, _dy);
if (_picdn)
_picdn->set_pos(_dx+DEPTH, _dy+DEPTH);
*/
_accel = -1;
}
@ -629,14 +631,13 @@ void TPush_button::draw_pressed(bool pressed) const
if (_picup)
{
const TImage* i = pressed ? _picdn : _picup;
if (i == NULL)
{
RCT dst = _picup->rect();
const TImage* i = (pressed && _picdn) ? _picdn : _picup;
RCT dst = i->rect();
if (pressed)
xvt_rect_offset(&dst, _dx+DEPTH, _dy+DEPTH);
_picup->draw(_hdc, dst);
}
else i->draw(_hdc);
else
xvt_rect_offset(&dst, _dx, _dy);
i->draw(_hdc, dst);
}
else
{

View File

@ -18,17 +18,20 @@
#include <scanner.h>
#include <utility.h>
#if XVT_OS==XVT_OS_SCOUNIX
#if XVT_OS==XVT_OS_WIN
#include <process.h>
#else
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#else
#include <direct.h>
#include <process.h>
#endif
#define NOT_LINKED(i,f) CHECKS(i != NULL, "Record senza tracciato: impossibile eseguire ", f)
#define NOT_OPEN(f) CHECKS(_isamfile != NULL, "File chiuso: ", f)
#define NOT_OPEN() CHECKS(_isamfile != NULL, "File chiuso: ", (const char*)name())
HIDDEN TString256 _isam_string;
HIDDEN void UNKNOWN_FIELD(int num, const char* name)
{ yesnofatal_box("Il campo '%s' non appartiene al file %d", name, num); }
@ -47,7 +50,12 @@ void set_autoload_new_files(bool on)
///////////////////////////////////////////////////////////
class TExtrectype : public TRectype
{
{
RecDes* _rd;
protected: // TRectype
virtual RecDes* rec_des() const { return _rd; }
public:
// FPUB
@ -61,8 +69,9 @@ TExtrectype::TExtrectype(const TTrec& r) : TRectype(6)
delete _rec;
_length = r.len();
_rec = new char [ _length ];
_i = new isdef;
_i->r = r.rec();
// _i = new isdef;
// _i->r = r.rec();
_rd = r.rec();
zero();
}
@ -70,7 +79,7 @@ TExtrectype::~TExtrectype()
{
delete _rec;
delete _i;
// delete _i;
}
///////////////////////////////////////////////////////////
@ -198,9 +207,9 @@ long TBaseisamfile::items() const
}
const char* TBaseisamfile::name() const
{
sprintf(__tmp_string, "%d", num());
return __tmp_string;
{
_isam_string.format("%d", num());
return _isam_string;
}
const char* TBaseisamfile::filename() const
@ -209,7 +218,8 @@ const char* TBaseisamfile::filename() const
{
TDir d;
d.get(num());
return strcpy(__tmp_string, d.name());
_isam_string = d.name();
return _isam_string;
}
return _isamfile->d->SysName;
}
@ -220,7 +230,8 @@ const char* TBaseisamfile::description() const
{
TDir d;
d.get(num());
return strcpy(__tmp_string, d.des());
_isam_string = d.des();
return _isam_string;
}
return _isamfile->d->Des;
}
@ -229,23 +240,22 @@ const char* TBaseisamfile::description() const
void TBaseisamfile::setkey(int nkey)
{
CHECKD(nkey > 0 && nkey - 1 <= _isamfile->r->NKeys, "Chiave non valida n.ro ", nkey);
NOT_OPEN(name());
CHECKD(nkey > 0 && nkey-1 <= _isamfile->r->NKeys, "Chiave non valida ", nkey);
NOT_OPEN();
_isamfile->i.PN = nkey - 1;
}
int TBaseisamfile::getkey() const
{
NOT_OPEN(name());
NOT_OPEN();
return _isamfile->i.PN + 1;
}
int TBaseisamfile::first(word lockop)
{
NOT_OPEN(name());
NOT_OPEN();
curr().setdirty();
cisread(_isamfile, curr().string(), _isfirst + lockop, &_lasterr);
_recno = _isamfile->RecNo;
@ -256,7 +266,7 @@ int TBaseisamfile::first(word lockop)
int TBaseisamfile::last(word lockop)
{
NOT_OPEN(name());
NOT_OPEN();
curr().setdirty();
cisread(_isamfile, curr().string(), _islast + lockop, &_lasterr);
_recno = _isamfile->RecNo;
@ -267,7 +277,7 @@ int TBaseisamfile::last(word lockop)
int TBaseisamfile::next(word lockop)
{
NOT_OPEN(name());
NOT_OPEN();
curr().setdirty();
cisread(_isamfile, curr().string(), _isnext + lockop, &_lasterr);
_recno = _isamfile->RecNo;
@ -283,7 +293,7 @@ int TBaseisamfile::next(TDate& atdate)
fd(wr, RFLD_SYS_DATE);
TRecnotype wrn;
NOT_OPEN(name());
NOT_OPEN();
if (!_historicfile)
error_box("%s not historic file", filename());
if (_lasthf == -1L) return _iseof;
@ -312,7 +322,7 @@ int TBaseisamfile::next(TDate& atdate)
int TBaseisamfile::prev(word lockop)
{
NOT_OPEN(name());
NOT_OPEN();
curr().setdirty();
cisread(_isamfile, curr().string(), _isprev + lockop, &_lasterr);
_recno = _isamfile->RecNo;
@ -327,7 +337,7 @@ int TBaseisamfile::prev(TDate& atdate)
fd(curr(), RFLD_SYS_DATE);
TRecnotype wrn;
NOT_OPEN(name());
NOT_OPEN();
if (!_historicfile)
error_box("%s not historic file", filename());
if (_lasthf == -1L) return _isbof;
@ -347,7 +357,7 @@ int TBaseisamfile::prev(TDate& atdate)
int TBaseisamfile::reread(word lockop, TDate& atdate)
{
NOT_OPEN(name());
NOT_OPEN();
curr().setdirty();
if ((!_historicfile) || (atdate == botime))
@ -365,7 +375,7 @@ int TBaseisamfile::reread(word lockop, TDate& atdate)
int TBaseisamfile::reread(TRectype& rec, word lockop, TDate& atdate)
{
NOT_OPEN(name());
NOT_OPEN();
rec.setdirty();
if ((!_historicfile) || (atdate == botime))
cisread(_isamfile, rec.string(), _iscurr + lockop, &_lasterr);
@ -382,7 +392,7 @@ int TBaseisamfile::reread(TRectype& rec, word lockop, TDate& atdate)
int TBaseisamfile::skip(TRecnotype nrec, word lockop)
{
NOT_OPEN(name());
NOT_OPEN();
if (!nrec) return NOERR;
curr().setdirty();
if (nrec >0)
@ -398,7 +408,7 @@ int TBaseisamfile::read(word op, word lockop, TDate& atdate)
{
CHECKD(op >= _iscurr && op <= _isgteq, "Invalid read operation : ", op);
NOT_OPEN(name());
NOT_OPEN();
curr().setdirty();
if ((!_historicfile) || (atdate == botime))
cisread(_isamfile, curr().string(), op + lockop, &_lasterr);
@ -416,7 +426,7 @@ int TBaseisamfile::read(TRectype& rec, word op, word lockop, TDate& atdate)
{
CHECKD(op >= _iscurr && op <= _isgteq, "Invalid read operation : ", op);
NOT_OPEN(name());
NOT_OPEN();
rec.setdirty();
if ((!_historicfile) || (atdate == botime))
cisread(_isamfile, rec.string(), op + lockop, &_lasterr);
@ -433,7 +443,7 @@ int TBaseisamfile::read(TRectype& rec, word op, word lockop, TDate& atdate)
int TBaseisamfile::readat(TRecnotype nrec, word lockop)
{
NOT_OPEN(name());
NOT_OPEN();
curr().setdirty();
cisreadrec(_isamfile, nrec, curr().string(), lockop, &_lasterr);
_recno = _isamfile->RecNo;
@ -444,7 +454,7 @@ int TBaseisamfile::readat(TRecnotype nrec, word lockop)
int TBaseisamfile::readat(TRectype& rec, TRecnotype nrec, word lockop)
{
NOT_OPEN(name());
NOT_OPEN();
rec.setdirty();
cisreadrec(_isamfile, nrec, rec.string(), lockop, &_lasterr);
_recno = _isamfile->RecNo;
@ -455,7 +465,7 @@ int TBaseisamfile::readat(TRectype& rec, TRecnotype nrec, word lockop)
int TBaseisamfile::write(TDate& atdate)
{
NOT_OPEN(name());
NOT_OPEN();
if ((!_historicfile) || (atdate == botime))
ciswrite(_isamfile, curr().string(), &_lasterr);
else
@ -468,7 +478,7 @@ int TBaseisamfile::write(TDate& atdate)
int TBaseisamfile::write(const TRectype& rec, TDate& atdate)
{
NOT_OPEN(_isamfile->d->SysName);
NOT_OPEN();
if ((!_historicfile) || (atdate == botime))
ciswrite(_isamfile, rec.string(), &_lasterr);
else
@ -481,7 +491,7 @@ int TBaseisamfile::write(const TRectype& rec, TDate& atdate)
int TBaseisamfile::rewrite(TDate& atdate)
{
NOT_OPEN(name());
NOT_OPEN();
if ((!_historicfile) || (atdate == botime))
cisrewrite(_isamfile, curr().string(), &_lasterr);
else
@ -494,7 +504,7 @@ int TBaseisamfile::rewrite(TDate& atdate)
int TBaseisamfile::rewrite(const TRectype& rec, TDate& atdate)
{
NOT_OPEN(name());
NOT_OPEN();
if ((!_historicfile) || (atdate == botime))
cisrewrite(_isamfile, rec.string(), &_lasterr);
else
@ -507,7 +517,7 @@ int TBaseisamfile::rewrite(const TRectype& rec, TDate& atdate)
int TBaseisamfile::rewriteat(TRecnotype nrec)
{
NOT_OPEN(name());
NOT_OPEN();
return cisrewrec(_isamfile, nrec, curr().string(), &_lasterr);
}
@ -515,7 +525,7 @@ int TBaseisamfile::rewriteat(TRecnotype nrec)
int TBaseisamfile::rewriteat(const TRectype& rec, TRecnotype nrec)
{
NOT_OPEN(name());
NOT_OPEN();
return cisrewrec(_isamfile, nrec, curr().string(), &_lasterr);
}
@ -523,7 +533,7 @@ int TBaseisamfile::rewriteat(const TRectype& rec, TRecnotype nrec)
int TBaseisamfile::remove(TDate& atdate)
{
NOT_OPEN(name());
NOT_OPEN();
if ((!_historicfile) || (atdate == botime))
cisdelete(_isamfile, curr().string(), &_lasterr);
else
@ -536,7 +546,7 @@ int TBaseisamfile::remove(TDate& atdate)
int TBaseisamfile::remove(const TRectype& rec, TDate& atdate)
{
NOT_OPEN(name());
NOT_OPEN();
if ((!_historicfile) || (atdate == botime))
cisdelete(_isamfile, rec.string(), &_lasterr);
else
@ -549,7 +559,7 @@ int TBaseisamfile::remove(const TRectype& rec, TDate& atdate)
int TBaseisamfile::lock()
{
NOT_OPEN(name());
NOT_OPEN();
return cislock(_isamfile, &_lasterr);
}
@ -557,7 +567,7 @@ int TBaseisamfile::lock()
int TBaseisamfile::unlock()
{
NOT_OPEN(name());
NOT_OPEN();
return cisunlock(_isamfile, &_lasterr);
}
@ -586,10 +596,9 @@ void TBaseisamfile::indexoff()
int TBaseisamfile::_open(unsigned int mode)
{
int err;
CHECKS(filehnd() == NULL, "File already open ", (const char*)filename());
if (filehnd() != NULL)
fatal_box("Il file %d e' gia' aperto", _logicnum);
int err;
if ((cisopen(&_isamfile, _logicnum, NOALLOC, mode, &err) == NOERR) &&
(_historicfile))
@ -620,7 +629,7 @@ int TBaseisamfile::_open(unsigned int mode)
recover();
}
_recno = -1L;
_current->_i = filehnd();
// _current->_i = filehnd();
setstatus(err);
return err;
}
@ -636,7 +645,7 @@ int TBaseisamfile::_close()
cisclose(ptrfilehnd(), NULL, &err);
clearfilehnd();
}
_current->_i = NULL;
// _current->_i = NULL;
setstatus(err);
return err;
}
@ -707,7 +716,7 @@ int TLocalisamfile::open(unsigned int mode)
err = _open();
_was_open = TRUE;
}
_current->_i = filehnd();
// _current->_i = filehnd();
setstatus(err);
return err;
@ -760,7 +769,7 @@ int TIsamfile::flags(bool updateeod)
{
int err;
NOT_OPEN(name());
NOT_OPEN();
setstatus(err);
return cisupdflags(filehnd(), &err, updateeod);
}
@ -801,7 +810,7 @@ TIsamtempfile::TIsamtempfile(int logicnum, const char* radix, bool create)
FILE* f = fopen(n, "r");
#if XVT_OS != XVT_OS_SCOUNIX
#if XVT_OS == XVT_OS_WIN
CHECKS(f, "Can't open temporary file ", (const char*)strerror(NULL));
#else
CHECKS(f, "Can't open temporary file ", (const char*)n);
@ -834,10 +843,9 @@ TIsamtempfile::~TIsamtempfile()
int TIsamtempfile::open(const char* radix, bool create, TRecnotype eod, TRecnotype eox)
{
int err;
CHECKS(filehnd() == NULL, "File already open", (const char*)filename());
if (filehnd() != NULL)
fatal_box("File %s already open", filename());
int err;
if ((cisopentemp(ptrfilehnd(), _logicnum, (char*)radix, NOALLOC, create, eod, eox, &err) == NOERR) &&
(_historicfile))
{
@ -857,7 +865,7 @@ int TIsamtempfile::open(const char* radix, bool create, TRecnotype eod, TRecnoty
_hfhd.len() = sizeof(TRecnotype);
_hfhd.base() = 0;
}
_current->_i = filehnd();
// _current->_i = filehnd();
_recno = -1L;
setstatus(err);
return err;
@ -873,7 +881,7 @@ int TIsamtempfile::close()
cisclosetemp(ptrfilehnd(), NULL, _autodel, &err);
clearfilehnd();
}
_current->_i = NULL;
// _current->_i = NULL;
setstatus(err);
return err;
}
@ -885,10 +893,9 @@ int TIsamtempfile::close()
int TSystemisamfile::build(TRecnotype eox)
{
int err;
CHECKS(filehnd() == NULL, "Can't build open file", (const char*)filename());
if(filehnd() != NULL)
fatal_box("Can't recreate open file %s", filename());
int err;
TDir d;
d.get(num());
@ -896,11 +903,8 @@ int TSystemisamfile::build(TRecnotype eox)
f = f.path();
if (!fexist(f))
#if XVT_OS==XVT_OS_SCOUNIX
mkdir(f, 0777);
#else
mkdir(f);
#endif
make_dir(f);
cisbuild(filehnd(), num(), eox, &err);
setstatus(err);
clearfilehnd();
@ -923,10 +927,8 @@ int TSystemisamfile::build(TRecnotype eox)
int TSystemisamfile::extend(TRecnotype eox)
{
int err;
if (filehnd() != NULL)
fatal_box("Can't extend open file %s", filename());
CHECKS(filehnd() == NULL, "Can't extend open file ", (const char*)filename());
int err;
cisextend(filehnd(), num(), eox, &err);
setstatus(err);
clearfilehnd();
@ -973,7 +975,7 @@ bool TSystemisamfile::exec_convapp(long flev, const bool before)
}
else err = 16;
if (err)
return error_box("Non posso eseguire il programma di %sconversione\ndel livello %ld/%ld\nErrore n.ro %d", before ? "pre" : "post", l / 100, l % 100, err);
return error_box("Impossibile eseguire il programma di %sconversione\ndel livello %ld/%ld\nErrore n.ro %d", before ? "pre" : "post", l / 100, l % 100, err);
}
}
return TRUE;
@ -1029,9 +1031,8 @@ void TSystemisamfile::makelc(TRectype& rec)
int TSystemisamfile::update(TTrec& newrec, bool vis)
{
if (filehnd() != NULL)
fatal_box("Can't update description for open file %s", filename());
{
CHECKS(filehnd() == NULL, "Can't update open file", (const char*)filename());
TDir dir;
@ -1126,11 +1127,10 @@ int TSystemisamfile::update(TTrec& newrec, bool vis)
int TSystemisamfile::packfile(bool vis)
{
{
CHECKS(filehnd() == NULL, "Can't pack open file", (const char*)filename());
int err;
if (filehnd() != NULL)
fatal_box("Can't pack open file %s", filename());
setstatus(creorgfile(num(), vis, &err));
return err;
@ -1140,10 +1140,8 @@ int TSystemisamfile::packfile(bool vis)
int TSystemisamfile::packindex(bool vis)
{
CHECKS(filehnd() == NULL, "Can't pack index of open file", (const char*)filename());
int err;
if (filehnd() != NULL)
fatal_box("Can't pack open file %s", filename());
setstatus(creorgindex(num(), vis, &err));
return err;
}
@ -1487,9 +1485,7 @@ void TBaseisamfile::recover()
// TRectype
////////////////////////////////////////////////////////////
TRectype::TRectype(int logicnum)
: _cod(NULL)
TRectype::TRectype(int logicnum) : _cod(NULL)
{
TDir wdir;
@ -1499,14 +1495,13 @@ TRectype::TRectype(int logicnum)
wdir.get(_logicnum, _nolock, _comdir, _sysdirop);
_length = wdir.len();
_rec = new char [ _length ];
_i = openf[_logicnum - 1];
// _i = openf[_logicnum - 1];
*_tab = '\0';
setempty(TRUE);
}
TRectype::TRectype(const TBaseisamfile* i)
: _cod(NULL)
TRectype::TRectype(const TBaseisamfile* i) : _cod(NULL)
{
_logicnum = i->num();
if (i->filehnd() != NULL)
@ -1522,7 +1517,7 @@ TRectype::TRectype(const TBaseisamfile* i)
}
*_tab = '\0';
_rec = new char [ _length ];
_i = i->filehnd();
// _i = i->filehnd();
setempty(TRUE);
}
@ -1536,7 +1531,7 @@ TRectype::TRectype(const TRectype& r)
_rec = new char [ _length ];
_rec[0] = r._rec[0];
memcpy(_rec + 1, r._rec + 1, _length - 1);
_i = r._i;
// _i = r._i;
strcpy(_tab, r._tab);
if (r._cod != NULL)
_cod = new TRecfield(*this, "COD");
@ -1609,17 +1604,26 @@ HIDDEN int fld_cmp(const char* a, const char* b, int len, bool number)
// TRectype (record di un file)
///////////////////////////////////////////////////////////
RecDes* TRectype::rec_des() const
{
const isdef* i = openf[_logicnum-1];
NOT_LINKED(i, "Record description");
RecDes* r = i->r;
CHECK(r, "Missing record description");
return r;
}
int TRectype::items() const
{
return _i->r->NFields;
return rec_des()->NFields;
}
const char* TRectype::start(int nf) const
{
return string() + _i->r->Fd[nf].RecOff;
return string() + rec_des()->Fd[nf].RecOff;
}
@ -1634,11 +1638,11 @@ int TRectype::compare(const TSortable& s) const
{
const char* b = br.start(i);
const char* a = start(i);
const byte typ = _i->r->Fd[i].TypeF;
const byte typ = rec_des()->Fd[i].TypeF;
/* if (typ == _boolfld) res = *a - *b;
else
{ */
const int sz = _i->r->Fd[i].Len;
const int sz = rec_des()->Fd[i].Len;
const bool number = (typ == _intfld) || (typ == _realfld) ||
(typ == _longfld) || (typ == _wordfld) ||
(typ == _intzerofld) || (typ == _longzerofld)
@ -1656,81 +1660,78 @@ int TRectype::compare(const TSortable& s) const
TFieldtypes TRectype::type(const char* fieldname) const
{
NOT_LINKED(_i, "type");
return (TFieldtypes) CFieldType((char*) fieldname, _i->r);
// NOT_LINKED(_i, "type");
return (TFieldtypes) CFieldType((char*) fieldname, rec_des());
}
int TRectype::length(const char* fieldname) const
{
NOT_LINKED(_i, "length");
return CFieldSize((char*) fieldname, _i->r);
// NOT_LINKED(_i, "length");
return CFieldSize((char*) fieldname, rec_des());
}
int TRectype::ndec(const char* fieldname) const
{
NOT_LINKED(_i, "dec");
return CFieldDec((char*) fieldname, _i->r);
// NOT_LINKED(_i, "dec");
return CFieldDec((char*) fieldname, rec_des());
}
bool TRectype::exist(const char* fieldname) const
{
NOT_LINKED(_i, "exist");
return findfld(_i->r, (char*)fieldname) != -1;
// NOT_LINKED(_i, "exist");
return findfld(rec_des(), (char*)fieldname) != -1;
}
const char* TRectype::fieldname(int i) const
{
NOT_LINKED(_i, "fieldname");
return i >= 0 && i < _i->r->NFields ? _i->r->Fd[i].Name : NULL;
// NOT_LINKED(_i, "fieldname");
RecDes* rd = rec_des();
return i >= 0 && i < rd->NFields ? rd->Fd[i].Name : NULL;
}
#ifndef FOXPRO
int TRectype::get_int(const char* fieldname) const
{
NOT_LINKED(_i, "get_int");
if (CGetFieldBuff((char*) fieldname, _i->r, _rec, __tmp_string) == -1)
// NOT_LINKED(_i, "get_int");
if (CGetFieldBuff((char*) fieldname, rec_des(), _rec, (char*)(const char*)_isam_string) == -1)
UNKNOWN_FIELD(num(), fieldname);
return atoi(__tmp_string);
return atoi(_isam_string);
}
long TRectype::get_long(const char* fieldname) const
{
NOT_LINKED(_i, "get_long");
if (CGetFieldBuff((char*) fieldname, _i->r, _rec, __tmp_string) == -1)
// NOT_LINKED(_i, "get_long");
if (CGetFieldBuff((char*) fieldname, rec_des(), _rec, (char*)(const char*)_isam_string) == -1)
UNKNOWN_FIELD(num(), fieldname);
return atol(__tmp_string);
return atol(_isam_string);
}
word TRectype::get_word(const char* fieldname) const
{
NOT_LINKED(_i, "get_word");
if (CGetFieldBuff((char*) fieldname, _i->r, _rec, __tmp_string) == -1)
// NOT_LINKED(_i, "get_word");
if (CGetFieldBuff((char*) fieldname, rec_des(), _rec, (char*)(const char*)_isam_string) == -1)
UNKNOWN_FIELD(num(), fieldname);
return (word)atoi(__tmp_string);
return (word)atoi(_isam_string);
}
real TRectype::get_real(const char* fieldname) const
{
NOT_LINKED(_i, "get_real");
if (CGetFieldBuff((char*) fieldname, _i->r, _rec, __tmp_string) == -1)
// NOT_LINKED(_i, "get_real");
if (CGetFieldBuff((char*) fieldname, rec_des(), _rec, (char*)(const char*)_isam_string) == -1)
UNKNOWN_FIELD(num(), fieldname);
real r(__tmp_string);
real r(_isam_string);
return r;
}
@ -1738,21 +1739,21 @@ real TRectype::get_real(const char* fieldname) const
char TRectype::get_char(const char* fieldname) const
{
NOT_LINKED(_i, "get_char");
// NOT_LINKED(_i, "get_char");
if (CGetFieldBuff((char*) fieldname, _i->r, _rec, __tmp_string) == -1)
if (CGetFieldBuff((char*) fieldname, rec_des(), _rec, (char*)(const char*)_isam_string) == -1)
UNKNOWN_FIELD(num(), fieldname);
return *__tmp_string;
return *_isam_string;
}
bool TRectype::get_bool(const char* fieldname) const
{
NOT_LINKED(_i, "get_bool");
if (CGetFieldBuff((char*) fieldname, _i->r, _rec, __tmp_string) == -1)
// NOT_LINKED(_i, "get_bool");
if (CGetFieldBuff((char*) fieldname, rec_des(), _rec, (char*)(const char*)_isam_string) == -1)
UNKNOWN_FIELD(num(), fieldname);
return *__tmp_string == 'X';
return *_isam_string == 'X';
}
#endif // FOXPRO
@ -1761,7 +1762,7 @@ bool TRectype::get_bool(const char* fieldname) const
TDate TRectype::get_date(const char* fieldname) const
{
NOT_LINKED(_i, "get_date");
// NOT_LINKED(_i, "get_date");
const TRecfield f((TRectype&)*this, fieldname);
return (TDate) f;
@ -1769,21 +1770,19 @@ TDate TRectype::get_date(const char* fieldname) const
const TString& TRectype::get(const char* fieldname) const
{
static TFixed_string s(__tmp_string, 256);
RecDes* rd = rec_des();
NOT_LINKED(_i, "get");
if (CFieldType((char*) fieldname, _i->r) == _datefld)
if (CFieldType((char*) fieldname, rd) == _datefld)
{
const TRecfield f((TRectype&)*this, fieldname);
s = (const char*) f;
_isam_string = (const char*) f;
}
else
if (CGetFieldBuff((char*) fieldname, _i->r, _rec, __tmp_string) == -1)
if (CGetFieldBuff((char*) fieldname, rd, _rec, (char*)(const char*)_isam_string) == -1)
UNKNOWN_FIELD(num(), fieldname);
return s;
return _isam_string;
}
@ -1792,8 +1791,8 @@ const TString& TRectype::get(const char* fieldname) const
void TRectype::put(const char* fieldname, int val)
{
NOT_LINKED(_i, "put");
if (CPutField((char*) fieldname, _i->r, &val, _rec) == -1)
// NOT_LINKED(_i, "put");
if (CPutField((char*) fieldname, rec_des(), &val, _rec) == -1)
UNKNOWN_FIELD(num(), fieldname);
setempty(FALSE);
}
@ -1802,8 +1801,8 @@ void TRectype::put(const char* fieldname, int val)
void TRectype::put(const char* fieldname, long val)
{
NOT_LINKED(_i, "put");
if (CPutField((char*) fieldname, _i->r, &val, _rec) == -1)
// NOT_LINKED(_i, "put");
if (CPutField((char*) fieldname, rec_des(), &val, _rec) == -1)
UNKNOWN_FIELD(num(), fieldname);
setempty(FALSE);
}
@ -1812,8 +1811,8 @@ void TRectype::put(const char* fieldname, long val)
void TRectype::put(const char* fieldname, word val)
{
NOT_LINKED(_i, "put");
if (CPutField((char*) fieldname, _i->r, &val, _rec) == -1)
// NOT_LINKED(_i, "put");
if (CPutField((char*) fieldname, rec_des(), &val, _rec) == -1)
UNKNOWN_FIELD(num(), fieldname);
setempty(FALSE);
}
@ -1821,8 +1820,8 @@ void TRectype::put(const char* fieldname, word val)
void TRectype::put(const char* fieldname, const real& val)
{
NOT_LINKED(_i, "put");
if (CPutField((char*) fieldname, _i->r, val.ptr(), _rec) == -1)
// NOT_LINKED(_i, "put");
if (CPutField((char*) fieldname, rec_des(), val.ptr(), _rec) == -1)
UNKNOWN_FIELD(num(), fieldname);
setempty(FALSE);
}
@ -1830,7 +1829,7 @@ void TRectype::put(const char* fieldname, const real& val)
void TRectype::put(const char* fieldname, const TDate& val)
{
NOT_LINKED(_i, "put");
// NOT_LINKED(_i, "put");
TRecfield f(*this, fieldname);
f = val.string(4);
setempty(FALSE);
@ -1839,10 +1838,10 @@ void TRectype::put(const char* fieldname, const TDate& val)
void TRectype::put(const char* fieldname, char val)
{
NOT_LINKED(_i, "put");
// NOT_LINKED(_i, "put");
char w[2] = {val, '\0'};
if (CPutFieldBuff((char*) fieldname, _i->r, w, _rec) == -1)
if (CPutFieldBuff((char*) fieldname, rec_des(), w, _rec) == -1)
UNKNOWN_FIELD(num(), fieldname);
setempty(FALSE);
}
@ -1851,9 +1850,9 @@ void TRectype::put(const char* fieldname, char val)
void TRectype::put(const char* fieldname, bool val)
{
NOT_LINKED(_i, "put");
// NOT_LINKED(_i, "put");
char* s = val ? "X" : " ";
if (CPutFieldBuff((char*) fieldname, _i->r, s, _rec) == -1)
if (CPutFieldBuff((char*) fieldname, rec_des(), s, _rec) == -1)
UNKNOWN_FIELD(num(), fieldname);
setempty(FALSE);
}
@ -1864,7 +1863,7 @@ void TRectype::put(const char* fieldname, bool val)
void TRectype::put(const char* fieldname, const char* val)
{
NOT_LINKED(_i, "put");
// NOT_LINKED(_i, "put");
if (val == NULL || *val == '\0') // Da provare
{
@ -1872,13 +1871,13 @@ void TRectype::put(const char* fieldname, const char* val)
if (*f.pos() == '\0') return;
}
if (CFieldType((char*) fieldname, _i->r) == _datefld)
if (CFieldType((char*) fieldname, rec_des()) == _datefld)
{
TRecfield f(*this, fieldname);
f = val;
}
else
if (CPutFieldBuff((char*) fieldname, _i->r, (char*) val, _rec) == -1)
if (CPutFieldBuff((char*) fieldname, rec_des(), (char*) val, _rec) == -1)
UNKNOWN_FIELD(num(), fieldname);
setempty(FALSE);
}
@ -1887,11 +1886,11 @@ void TRectype::put(const char* fieldname, const char* val)
void TRectype::zero(const char* fieldname)
{
NOT_LINKED(_i, "zero");
// NOT_LINKED(_i, "zero");
if (_cod != NULL && strcmp(fieldname , "COD") == 0)
*_cod = _tab;
else
if (CZeroField((char*) fieldname, _i->r, _rec) == -1)
if (CZeroField((char*) fieldname, rec_des(), _rec) == -1)
UNKNOWN_FIELD(num(), fieldname);
}
@ -1906,7 +1905,7 @@ void TRectype::zero()
void TRectype::zero(char c)
{
NOT_LINKED(_i, "zero");
// NOT_LINKED(_i, "zero");
recall();
memset(_rec + 1, c, len() - 1);
@ -1923,7 +1922,7 @@ TRectype& TRectype::operator =(const TRectype& rec)
{
CHECK(num() == rec.num(), "Can't assign records of different file");
_i = rec._i; // Copy filehndl
// _i = rec._i; // Copy filehndl
memcpy(_rec, rec._rec, _length); // Copy contents
setempty(rec.empty()); // Copy emptiness status
return *this;
@ -1948,21 +1947,11 @@ TRectype& TRectype::operator =(const char* rec)
const char* TRectype::key(int numkey) const
{
NOT_LINKED(_i, "key");
CBuildKey(_i->r, numkey, _rec, __tmp_string);
return __tmp_string;
// NOT_LINKED(_i, "key");
CBuildKey(rec_des(), numkey, _rec, (char*)(const char*)_isam_string);
return _isam_string;
}
TRec_array::TRec_array(int dimension, TBaseisamfile& i)
: TArray(dimension)
{
TRectype r(&i);
for (int j = 0 ; j < size(); j++) add(r, j);
}
///////////////////////////////////////////////////////////
// TRecfield (campo/sottocampo di un record)
///////////////////////////////////////////////////////////
@ -1971,9 +1960,9 @@ void TRecfield::set(int from, int to)
{
int nf;
const isdef* bf = _rec->filehnd();
RecDes* rd = _rec->rec_des();
if ((nf = findfld(bf->r, _name)) == -1)
if ((nf = findfld(rd, _name)) == -1)
{
_p = NULL;
_len = 0;
@ -1984,24 +1973,24 @@ void TRecfield::set(int from, int to)
else
{
CHECK(from >= 0, "Invalid Start");
_p = _rec->string() + bf->r->Fd[nf].RecOff + from;
_dec = bf->r->Fd[nf].Dec;
_type = bf->r->Fd[nf].TypeF;
_p = _rec->string() + rd->Fd[nf].RecOff + from;
_dec = rd->Fd[nf].Dec;
_type = rd->Fd[nf].TypeF;
if (to >= 0)
{
CHECK(from <= to && to <= bf->r->Fd[nf].Len,
CHECK(from <= to && to <= rd->Fd[nf].Len,
"Invalid Range");
_len = to - from + 1;
}
else _len = bf->r->Fd[nf].Len - from;
else _len = rd->Fd[nf].Len - from;
}
}
TRecfield::TRecfield(TRectype& rec, const char* name, int from, int to)
{
// NOT_LINKED(rec.filehnd(), "TRecfield");
strcpy(_name, name);
NOT_LINKED(rec.filehnd(), "TRecfield");
_rec = &rec;
set(from, to);
}
@ -2097,10 +2086,10 @@ int TRecfield::operator =(int i)
{
if (_type == _intzerofld)
sprintf(__tmp_string, "%0*d", _len, i);
_isam_string.format("%0*d", _len, i);
else
sprintf(__tmp_string, "%d", i);
__putfieldbuff( _len, _dec, _type, __tmp_string, _p);
_isam_string.format("%d", i);
__putfieldbuff( _len, _dec, _type, _isam_string, _p);
_rec->setempty(FALSE);
return i;
}
@ -2110,10 +2099,10 @@ long TRecfield::operator =(long l)
{
if (_type == _longzerofld)
sprintf(__tmp_string, "%0*ld", _len, l);
_isam_string.format("%0*ld", _len, l);
else
sprintf(__tmp_string, "%ld", l);
__putfieldbuff( _len, _dec, _type, __tmp_string, _p);
_isam_string.format("%ld", l);
__putfieldbuff( _len, _dec, _type, _isam_string, _p);
_rec->setempty(FALSE);
return l;
}
@ -2123,8 +2112,8 @@ long TRecfield::operator =(long l)
const real& TRecfield::operator =(const real& r)
{
strcpy(__tmp_string, r.string());
__putfieldbuff( _len, _dec, _type, __tmp_string, _p);
_isam_string = r.string();
__putfieldbuff( _len, _dec, _type, _isam_string, _p);
_rec->setempty(FALSE);
return r;
}
@ -2134,8 +2123,8 @@ const real& TRecfield::operator =(const real& r)
const TDate& TRecfield::operator =(const TDate& d)
{
strcpy(__tmp_string, (const char*) d);
__putfieldbuff( _len, _dec, _type, __tmp_string, _p);
_isam_string = (const char*)d;
__putfieldbuff( _len, _dec, _type, _isam_string, _p);
_rec->setempty(FALSE);
return d;
}
@ -2173,16 +2162,16 @@ void TRecfield::setptr(TRecnotype r)
TRecfield::operator int() const
{
__getfieldbuff( _len, _type, _p, __tmp_string);
return atoi(__tmp_string);
__getfieldbuff( _len, _type, _p, (char*)(const char*)_isam_string);
return atoi(_isam_string);
}
TRecfield::operator long() const
{
__getfieldbuff( _len, _type, _p, __tmp_string);
return atol(__tmp_string);
__getfieldbuff( _len, _type, _p, (char*)(const char*)_isam_string);
return atol(_isam_string);
}
@ -2191,8 +2180,8 @@ TRecfield::operator long() const
TRecfield::operator const real() const
{
__getfieldbuff( _len, _type, _p, __tmp_string);
real r(__tmp_string);
__getfieldbuff( _len, _type, _p, (char*)(const char*)_isam_string);
real r(_isam_string);
return r;
}
#endif // FOXPRO
@ -2202,8 +2191,8 @@ TRecfield::operator TDate() const
{
static TDate d;
__getfieldbuff( _len, _type, _p, __tmp_string);
d = __tmp_string;
__getfieldbuff( _len, _type, _p, (char*)(const char*)_isam_string);
d = _isam_string;
return d;
}
@ -2211,8 +2200,8 @@ TRecfield::operator TDate() const
TRecfield::operator const char*() const
{
__getfieldbuff( _len, _type, _p, __tmp_string);
return __tmp_string;
__getfieldbuff( _len, _type, _p, (char*)(const char*)_isam_string);
return _isam_string;
}

View File

@ -55,19 +55,20 @@ class TRectype : public TSortable
char* _rec; // Puntatore a inizio record
int _logicnum; // Numero logico
int _length; // Lunghezza
isdef* _i; // Puntatore al file isam
// isdef* _i; // Puntatore al file isam
bool _isempty; // Se il record e' vuoto
char _tab[5]; // identificatore della tabella
TRecfield * _cod; // campo "COD" della tabella
// @END
protected:
// FPROT
protected: // TObject
virtual TObject* dup() const; // Duplica record
virtual int compare(const TSortable& s) const;
protected:
const char* start(int nf) const;
void setempty(bool val) { _isempty = val;} // Rende vero is_empty
virtual TObject* dup() const; // Duplica record
virtual int compare(const TSortable& s) const;
// @END
virtual RecDes* rec_des() const;
public:
// FPUB
@ -128,12 +129,12 @@ public:
TRectype& operator =(const char* rec); // assegnazione tra TRectype
TRectype& operator =(const TBaseisamfile& f);
const isdef* filehnd() const { return _i; } // Ritorna il file isam associato
// const isdef* filehnd() const { return _i; } // Ritorna il file isam associato
int num() const { return _logicnum;} // Ritorna il numero logico
bool empty() const {return _isempty;} // Ritorna se e' vuoto
bool valid() const {return _rec[0] == 0;} // Ritorna se il record non e'cancellato
const char* key(int numkey = 1) const; // Ritorna l'espressione della chiave numero numkey
bool ok() const { return _i != NULL;}
bool ok() const { return _rec != NULL; }
TRectype(int logicnum); // Costruisce un record staccato da un file. Bisogna poi chiamare linkfile(). Sarebbe meglio utilizzare una delle altre due
TRectype(const TBaseisamfile* i); // Costruisce record e lo associa al file isam i

View File

@ -644,7 +644,6 @@ bool TMask_field::do_message(int num)
continue;
}
short fld = (dlg && dlg[0] > ' ') ? atodlg(dlg) : 0;
bool broadcast = dlg && strchr(dlg, '@');
if (value[0] == '"') value = value.strip("\"'");

View File

@ -165,11 +165,19 @@ TSpreadsheet::TSpreadsheet(short x, short y, short dx, short dy,
v = max(at, m+(f->has_query() ? 1 : 0));
}
else
{
{
m = testa.len();
v = m+(f->has_query() ? 1 : 0);
}
#ifdef DBG
if (f->is_edit() && m < f->size())
{
yesnofatal_box("Il campo %d della maschera e' piu' largo della colonna %s",
cid, (const char*)testa);
m = f->size();
}
#endif
m_width[i] = m+1; // m = number of allowed chars
v_width[i] = v+1; // v = width of column
if (v >= max_width) max_width = v+1;

View File

@ -1,3 +1,6 @@
#ifndef __PARTITE_H
#define __PARTITE_H
#define PART_ANNO "ANNO"
#define PART_NUMPART "NUMPART"
#define PART_NRIGA "NRIGA"
@ -37,3 +40,5 @@
#define PART_CHIUSA "CHIUSA"
#define PART_CODABIPR "CODABIPR"
#define PART_CODCABPR "CODCABPR"
#endif

View File

@ -233,7 +233,7 @@ bool TPrefix::test(const char* s) const
{
if (s && *s && strcmp(s, "DEF"))
{
TString80 s1(__ptprf);
TFilename s1(__ptprf);
s1 << s << "/dir.gen";
if (!fexist(s1))
return error_box("Impossibile trovare il file '%s'", (const char*)s1);

View File

@ -1,4 +1,4 @@
// $Id: relation.cpp,v 1.33 1995-03-22 09:06:27 guy Exp $
// $Id: relation.cpp,v 1.34 1995-04-10 15:27:51 guy Exp $
// relation.cpp
// fv 12/8/93
// relation class for isam files
@ -1299,20 +1299,19 @@ const char* TFieldref::read(const TRelation* c) const
void TFieldref::write(const char* val, TRelation* c) const
{
TLocalisamfile* f = NULL;
TRectype* curr = NULL;
if (c == NULL)
{
f = new TLocalisamfile(_fileid, TRUE);
curr = &f->curr();
{
#ifdef DBG
yesnofatal_box("Guy consiglia di dare un'occhiatina al codice!");
#endif
TLocalisamfile f(_fileid, TRUE);
write(val, f.curr());
}
else
curr = &c->lfile(_id).curr();
write(val, *curr);
if (f != NULL) delete f;
{
TRectype &curr = c->lfile(_id).curr();
write(val, curr);
}
}
@ -1321,7 +1320,7 @@ void TFieldref::write(const char* val, TRectype& rec) const
if (_fileid >= CNF_GENERAL) return;
if (_from > 0)
{
TString80 campo(rec.get(_name));
TString256 campo(rec.get(_name));
campo.overwrite(val, _from);
rec.put(_name, campo);
}
@ -1330,16 +1329,141 @@ void TFieldref::write(const char* val, TRectype& rec) const
}
int TFieldref::len(TRectype &rec) const
{
if (_to >= 0) return _to - _from;
if (_fileid == 0) return rec.length(_name) - _from;
if (_to >= 0)
return _to - _from;
if (_fileid == 0)
return rec.length(_name) - _from;
TLocalisamfile f(_fileid);
const int len = f.curr().length(_name);
const TRectype r(_fileid);
const int len = r.length(_name);
return len - _from;
}
///////////////////////////////////////////////////////////
// TRecord_Array
///////////////////////////////////////////////////////////
TRecord_array::TRecord_array(const TRectype& r, const char* numfield)
: _file(r.num()), _num(numfield)
{
read(r);
}
TRecord_array::TRecord_array(int logicnum, const char* numfield)
: _file(logicnum), _num(numfield)
{
}
int TRecord_array::rec2row(const TRectype& r) const
{
CHECK(r == key(), "Incompatible record");
const int n = atoi(r.get(_num)); // Non e' detto che sia un int!
CHECKD(n > 0 && n < 32000, "Bad line number in record ", n);
return n;
}
int TRecord_array::add_row(const TRectype& r)
{
const int nr = rec2row(r);
TRectype* o = (TRectype*)objptr(nr);
if (o) *o = r;
else add(r, nr);
return nr;
}
bool TRecord_array::destroy_row(int r)
{
CHECKD(r > 0, "Can't destroy row ", r);
return destroy(r);
}
void TRecord_array::destroy_rows()
{
const int u = last();
for (int i = 1; i <= u; i++)
destroy_row(i);
}
bool TRecord_array::read(const TRectype& filter)
{
CHECKD(filter.num() == _file, "Bad key record ", filter.num());
CHECKS(filter.get(_num).empty(), "You can't specify in the filter the value ", (const char*)_num);
destroy();
add(filter, 0); // Store filter record for later use
TLocalisamfile f(_file);
f.curr() = filter;
for (int err = f.read(_isgteq); err == NOERR && f.curr() == filter; err = f.next())
add_row(f.curr());
return ok();
}
bool TRecord_array::write(bool re)
{
int err = NOERR;
TLocalisamfile f(_file);
const int u = last();
for (int i = 1; i <= u; i++)
{
const TRectype* r = (TRectype*)objptr(i);
if (r != NULL)
{
err = re ? f.rewrite(*r) : f.write(*r);
if (err != NOERR);
err = re ? f.write(*r) : f.rewrite(*r);
if (err != NOERR)
return error_box("Errore di scrittura della riga %d", i);
}
else
{
f.curr() = key(); f.put(_num, i);
err = f.read();
if (err == NOERR) // La riga c'era ma ora non piu'
{
err = f.remove();
if (err != NOERR)
return error_box("Errore di cancellazione della riga %d", i);
}
}
}
// Cancella eventuali residui successivi
f.curr() = key(); f.put(_num, i);
for (err = f.read(_isgteq); err == NOERR && f.curr() == key(); err = f.next())
{
err = f.remove();
if (err != NOERR)
{
i = atoi(f.get(_num));
return error_box("Errore di cancellazione della riga %d", i);
}
}
return TRUE;
}
bool TRecord_array::remove()
{
destroy_rows();
TLocalisamfile f(_file);
f.curr() = key();
for (int err = f.read(_isgteq); err == NOERR && f.curr() == key(); err = f.next())
{
err = f.remove();
return error_box("Errore di cancellazione delle righe");
}
return TRUE;
}
// *** EOF relation.cpp

View File

@ -1,4 +1,4 @@
/* $Id: relation.h,v 1.12 1995-02-10 17:42:33 guy Exp $ */
/* $Id: relation.h,v 1.13 1995-04-10 15:27:53 guy Exp $ */
// join.h
// fv 12/8/93
// join class for isam files
@ -141,6 +141,44 @@ public:
virtual ~TRelation();
};
///////////////////////////////////////////////////////////
// TRecord_Array
///////////////////////////////////////////////////////////
class TRecord_array : private TArray
{
int _file;
TString16 _num;
private:
int rec2row(const TRectype& r) const;
const TRectype& key() const { return (const TRectype&)operator[](0); }
protected:
virtual bool destroy_row(int n);
public:
int rows() const { return items()-1; }
int last_row() const { return last(); }
const TRectype& row(int r) const
{ CHECKD(r > 0, "Bad record number ", r); return (TRectype&)operator[](r); }
virtual int add_row(const TRectype& r);
virtual bool destroy_row(const TRectype& r) { return destroy_row(rec2row(r)); }
void destroy_rows();
virtual bool read(const TRectype& r);
virtual bool write(bool re = FALSE);
virtual bool rewrite() { return write(TRUE); }
virtual bool remove();
TRecord_array(const TRectype& r, const char* numfield);
TRecord_array(int logicnum, const char* numfield);
};
// @C
// Classe TCursor : public TObject
//

View File

@ -1,23 +1,29 @@
#define SCAD_ANNO "ANNO"
#define SCAD_NUMPART "NUMPART"
#define SCAD_NRATA "NRATA"
#define SCAD_CODPAG "CODPAG"
#define SCAD_TIPOPAG "TIPOPAG"
#define SCAD_ULTCLASS "ULTCLASS"
#define SCAD_IMPORTO "IMPORTO"
#define SCAD_CODVAL "CODVAL"
#define SCAD_CAMBIO "CAMBIO"
#define SCAD_IMPORTOVAL "IMPORTOVAL"
#define SCAD_DATACAMBIO "DATACAM"
#define SCAD_DATASCAD "DATASCAD"
#define SCAD_TIPOCF "TIPOCF"
#define SCAD_GRUPPO "GRUPPO"
#define SCAD_CONTO "CONTO"
#define SCAD_SOTTOCONTO "SOTTOCONTO"
#define SCAD_NSOLL "NSOLL"
#define SCAD_DATASOLL "DATASOLL"
#define SCAD_GGRIT "GGRIT"
#define SCAD_PAGATA "PAGATA"
#define SCAD_IMPORTOPAG "IMPORTOPAG"
#define SCAD_CODABIPR "CODABIPR"
#define SCAD_CODCABPR "CODCABPR"
#ifndef __SCADENZE_H
#define __SCADENZE_H
#define SCAD_ANNO "ANNO"
#define SCAD_NUMPART "NUMPART"
#define SCAD_NRATA "NRATA"
#define SCAD_CODPAG "CODPAG"
#define SCAD_TIPOPAG "TIPOPAG"
#define SCAD_ULTCLASS "ULTCLASS"
#define SCAD_IMPORTO "IMPORTO"
#define SCAD_CODVAL "CODVAL"
#define SCAD_CAMBIO "CAMBIO"
#define SCAD_IMPORTOVAL "IMPORTOVAL"
#define SCAD_DATACAMBIO "DATACAM"
#define SCAD_DATASCAD "DATASCAD"
#define SCAD_TIPOCF "TIPOCF"
#define SCAD_GRUPPO "GRUPPO"
#define SCAD_CONTO "CONTO"
#define SCAD_SOTTOCONTO "SOTTOCONTO"
#define SCAD_NSOLL "NSOLL"
#define SCAD_DATASOLL "DATASOLL"
#define SCAD_GGRIT "GGRIT"
#define SCAD_PAGATA "PAGATA"
#define SCAD_IMPORTOPAG "IMPORTOPAG"
#define SCAD_CODABIPR "CODABIPR"
#define SCAD_CODCABPR "CODCABPR"
#endif

View File

@ -466,7 +466,7 @@ bool TSheet::update_row(long n)
if (chk)
{
set_color(MASK_BACK_COLOR, NORMAL_BACK_COLOR);
set_color(FOCUS_COLOR, NORMAL_BACK_COLOR);
changed = TRUE;
}
else if (_disabled[n])

View File

@ -13,11 +13,7 @@
#define FALSE 0
#define TRUE 1
#if XVT_OS==XVT_OS_WIN
#define HIDDEN static near
#else
#define HIDDEN static
#endif
#define EOL -1
#define NOERR 0

View File

@ -8,12 +8,12 @@
#include <prefix.h>
#include <utility.h>
#if XVT_OS==XVT_OS_SCOUNIX
#if XVT_OS==XVT_OS_WIN
#include <process.h>
#else
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#else
#include <process.h>
#endif
class TString512 : public TFixed_string
@ -258,7 +258,7 @@ bool TString::match(const char* s) const
return *s == '\0' && *me == '\0';
}
#if XVT_OS == XVT_OS_SCOUNIX
#if XVT_OS != XVT_OS_WIN
HIDDEN char* strstr(const char* string1, const char* string2)
{
const int len = strlen(string2);
@ -634,10 +634,10 @@ TString& TFixed_string::format(const char* fmt, ...)
///////////////////////////////////////////////////////////
const char SLASH =
#if XVT_OS == XVT_OS_SCOUNIX
'/';
#else
#if XVT_OS == XVT_OS_WIN
'\\';
#else
'/';
#endif
// Certified 90%
@ -699,7 +699,7 @@ bool TFilename::ok() const
{
switch(_str[c])
{
#if XVT_OS != XVT_OS_SCOUNIX
#if XVT_OS == XVT_OS_WIN
case ':':
if (c != 1 || !isalpha(_str[0])) return FALSE; // Nome disco errato
len = 0;
@ -740,10 +740,10 @@ const TFilename& TFilename::tempdir()
const char* dirpref = getenv("TEMP");
if (dirpref == NULL || *dirpref == '\0') dirpref = getenv("TMP");
if (dirpref == NULL || *dirpref == '\0')
#if XVT_OS==XVT_OS_SCOUNIX
dirpref = "/tmp";
#if XVT_OS==XVT_OS_WIN
dirpref = "\\tmp";
#else
dirpref = "\\tmp";
dirpref = "/tmp";
#endif
_tempdir = dirpref;
@ -791,10 +791,7 @@ const TFilename& TFilename::temp(const char* prefix)
strip("$#*?."); // ... toglie caratteri jolly
const TFixed_string f(prefix);
#if XVT_OS==XVT_OS_SCOUNIX
if (f.find("$$") != -1) *this << getpid();
if (f.find("##") != -1) *this << getuid();
#else
#if XVT_OS==XVT_OS_WIN
if (f.find("$$") != -1)
{
char pid[8];
@ -802,6 +799,9 @@ const TFilename& TFilename::temp(const char* prefix)
pid[3] = '\0';
*this << pid;
}
#else
if (f.find("$$") != -1) *this << getpid();
if (f.find("##") != -1) *this << getuid();
#endif
}
else cut(0);
@ -1131,4 +1131,4 @@ int TString_array::find(const char* s, int from) const
break;
}
return found;
}
}

View File

@ -3,42 +3,40 @@
#include <stdio.h>
#include <stdlib.h>
#ifndef FOXPRO
#include <xvt.h>
#endif
#if XVT_OS == XVT_OS_WIN
#include <direct.h>
#include <io.h>
#define F_OK 0
#else
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
int remove(const char* path)
{ return unlink(path); }
#endif
#define __UTILITY_CPP
#include <utility.h>
#if XVT_OS == XVT_OS_SCOUNIX
#include <unistd.h>
int remove(const char* path)
{ return unlink(path); }
#else
#include <io.h>
#define F_OK 0
#endif
bool fcopy(const char* orig, const char* dest, bool append)
{
const char* wflag;
#if XVT_OS == XVT_OS_SCOUNIX
const char* const rflag = "r";
if (append)
wflag = "a";
else
wflag = "w";
#else
#if XVT_OS == XVT_OS_WIN
const char* const rflag = "rb";
if (append)
wflag = "ab";
else
wflag = "wb";
#else
const char* const rflag = "r";
if (append)
wflag = "a";
else
wflag = "w";
#endif
FILE* i = fopen(orig, rflag);
@ -76,14 +74,16 @@ bool fexist(const char* file)
bool make_dir(const char* dir)
{
int res =
#if XVT_OS==XVT_OS_SCOUNIX
mkdir(dir, 0777);
#if XVT_OS==XVT_OS_WIN
mkdir(dir);
#else
mkdir(dir);
mkdir(dir, 0777);
#endif
return res == 0;
}
#ifndef FOXPRO
int list_files(TToken_string& filelist)
{
TFilename dir(filelist.get(0));
@ -122,6 +122,8 @@ int list_files(TToken_string& filelist)
return count;
}
#endif
// Best function of the year
// Certified 99%
char* format(const char* fmt, ...)
@ -308,7 +310,7 @@ const char * decode( const char * data)
return __tmp_string;
}
#if XVT_OS == XVT_OS_SCOUNIX
#if XVT_OS != XVT_OS_WIN
int stricmp(const char* s1, const char* s2)
{
@ -319,6 +321,8 @@ int stricmp(const char* s1, const char* s2)
}
#endif
#ifdef __WATCOMC__
char * tempnam(const char * dir , const char * prefix)

View File

@ -10,13 +10,20 @@ extern "C" { long nap(long period); }
#endif
#ifdef DBG
// FATAL_HOOK che intercetta errori fatali XVT
// ERROR HOOK che intercetta errori XVT
// put breakpoint here
void fatal_hook()
BOOLEAN error_hook(XVT_ERRMSG err, DATA_PTR)
{
int dummy = 0;
dummy++;
const XVT_ERRSEV sev = xvt_errmsg_get_sev_id(err);
#ifdef DBG
return FALSE;
#else
return sev < SEV_ERROR;
#endif
}
#endif
HIDDEN XVT_FNTID DEF_FONT = NULL;
@ -607,9 +614,7 @@ void customize_controls(bool on)
xvt_font_destroy(FAT_FONT);
}
#ifdef DBG
if (on) xvt_vobj_set_attr(NULL_WIN,ATTR_FATAL_ERR_HANDLER, (long)fatal_hook);
#endif
if (on) xvt_vobj_set_attr(NULL_WIN,ATTR_ERRMSG_HANDLER, (long)error_hook);
}
XVT_FNTID xvt_default_font()