Config Rimossa la creazione dei .bak

Isam      Aggiunti check sui record vuoti in scrittura
Maskfld   Tolti i simboli | da tutti i campi editabili
Msksheet  Corretto errore alla fine delle ricerche con F9 negli sheet
Relapp    Spostato l'azzeramento della relazione nella init_insert_mode
Relation  Aggiunti check per debug


git-svn-id: svn://10.65.10.50/trunk@1575 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1995-07-07 14:43:41 +00:00
parent 3ec89dfa54
commit 4938651fb0
6 changed files with 59 additions and 47 deletions

View File

@ -115,13 +115,12 @@ void TConfig::_write_file()
out.close(); in.close();
if (_file[0] > 'B' || _file[1] != ':') // Non creare il .bak su dischetto
{
while (access(_file, 02) != 0)
message_box("Il file %s e' gia' in uso", (const char*)_file);
TFilename bak(_file); bak.ext("bak");
rename(_file, bak);
}
while (access(_file, 02) != 0)
message_box("Il file %s e' gia' in uso", (const char*)_file);
/*
TFilename bak(_file); bak.ext("bak");
rename(_file, bak);
*/
fcopy(temp, _file); // Copia dalla tempdir al nuovo .ini
remove(temp); // Cancella file temporaneo
}

View File

@ -722,8 +722,9 @@ int TBaseisamfile::readat(TRectype& rec, TRecnotype nrec, word lockop)
int TBaseisamfile::write(TDate& atdate)
{
{
CHECK(!curr().empty(), "Can't write an empty record");
NOT_OPEN();
int oldkey=getkey();
browse_null(curr().string(),DB_reclen(_isamfile->fhnd));
@ -747,6 +748,8 @@ int TBaseisamfile::write(TDate& atdate)
int TBaseisamfile::write(const TRectype& rec, TDate& atdate)
{
CHECK(!rec.empty(), "Can't write an empty record");
NOT_OPEN();
int oldkey=getkey();
browse_null(rec.string(),DB_reclen(_isamfile->fhnd));
@ -770,6 +773,8 @@ int TBaseisamfile::write(const TRectype& rec, TDate& atdate)
int TBaseisamfile::rewrite(TDate& atdate)
{
CHECK(!curr().empty(), "Can't rewrite an empty record");
NOT_OPEN();
TRectype save_rec(curr());
@ -788,6 +793,8 @@ int TBaseisamfile::rewrite(TDate& atdate)
int TBaseisamfile::rewrite(const TRectype& rec, TDate& atdate)
{
CHECK(!rec.empty(), "Can't write an empty record");
NOT_OPEN();
TRectype save_rec(rec);
_lasterr = cisread(_isamfile, save_rec, _isequal + _nolock); // Si Posiziona per sicurezza...
@ -819,7 +826,6 @@ int TBaseisamfile::rewriteat(TRecnotype nrec)
int TBaseisamfile::rewriteat(const TRectype& rec, TRecnotype nrec)
{
NOT_OPEN();
if ((_lasterr=DB_go(_isamfile->fhnd,nrec))== NOERR)
@ -835,8 +841,9 @@ int TBaseisamfile::rewriteat(const TRectype& rec, TRecnotype nrec)
int TBaseisamfile::remove(TDate& atdate)
{
CHECK(!curr().empty(), "Can't remove empty record");
NOT_OPEN();
// rimozione campi memo
@ -882,6 +889,8 @@ int TBaseisamfile::remove(TDate& atdate)
int TBaseisamfile::remove(const TRectype& rec, TDate& atdate)
{
CHECK(!rec.empty(), "Can't remove an empty record");
NOT_OPEN();
memcpy(DB_getrecord(_isamfile->fhnd),rec.string(),DB_reclen(_isamfile->fhnd));
if ((_lasterr=cisread(_isamfile, (TRectype&) rec, _isequal + _lock))==NOERR)
@ -2797,7 +2806,6 @@ TRecnotype TRecfield::ptr() const
void TTransaction::begin()
{
}

View File

@ -2023,6 +2023,9 @@ const char* TEdit_field::format(const char* d)
if (_flags.uppercase)
fpark.upper();
for (int p = 0; fpark[p]; p++)
if (fpark[p] == '|') fpark[p] = '/';
}
return fpark;

View File

@ -667,7 +667,6 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev)
if (_row_dirty && _check_enabled)
{
_check_enabled = FALSE; // Avoid recursion!
// str2mask(_cur_rec); // It shouldn't have to be necessary
bool ok = sheet_mask().check_fields();
if (ok)
{
@ -715,8 +714,9 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev)
c->set_dirty(); // Get it dirty!
if (c->on_key(c->is_edit() ? K_TAB : K_SPACE) == FALSE) // Test it
xiev->refused = *nuo != '\0';
else
mask2str(_cur_rec); // Update sheet row
if (!xiev->refused)
mask2str(_cur_rec); // Update sheet row
}
_check_enabled = TRUE;
}
@ -761,6 +761,7 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev)
_lastab = _cur_col < 2 ? K_TAB : K_BTAB;
break;
case K_F1:
case K_SHIFT+K_F1:
_check_enabled = FALSE; // Disable checks
_edit_field->on_key(K_F1);
set_focus_cell(_cur_row, _cur_col);
@ -770,25 +771,30 @@ void TSpreadsheet::list_handler(XI_EVENT *xiev)
case K_F3:
case K_F8:
case K_F9:
case K_F11:
case K_F11:
if (_check_enabled && active())
{
_check_enabled = FALSE; // Disable checks
notify_change();
if (_edit_field->on_key(k) == FALSE && k == K_F9)
_check_enabled = FALSE; // Disable checks
notify_change();
const bool ok = _edit_field->on_key(k);
if (!ok && k == K_F9) // Ricerca non completata?
{
_edit_field = &_mask.fld(_mask.focus_field());
const short foca = _edit_field->dlg();
const int col = (foca - FIRST_FIELD) % 100 +1;
if (col > 0 && col != _cur_col)
if (col > 0 && col != _cur_col) // Ricerca alternativa
{
_cur_col = col;
dispatch_e_char(win(), K_F9);
}
}
mask2str(_cur_rec);
set_focus_cell(_cur_row, _cur_col);
_check_enabled = TRUE; // Enable checks
if (ok)
{
mask2str(_cur_rec);
update(_cur_rec); _needs_update = -1; // Update immediately!
set_focus_cell(_cur_row, _cur_col);
}
_check_enabled = TRUE; // Re-enable checks
}
break;
case K_PREV:

View File

@ -1,4 +1,4 @@
// $Id: relapp.cpp,v 1.61 1995-06-26 16:51:48 alex Exp $
// $Id: relapp.cpp,v 1.62 1995-07-07 14:43:39 guy Exp $
#include <mailbox.h>
#include <sheet.h>
#include <urldefid.h>
@ -423,6 +423,8 @@ void TRelation_application::insert_mode()
}
set_mode(MODE_INS);
get_relation()->zero(); // Azzera tutta la relazione!
init_insert_mode(*_mask);
}
@ -644,10 +646,8 @@ bool TRelation_application::save(bool check_dirty)
bool changed = TRUE;
bool changed_key = FALSE;
get_relation()->zero(); // Azzera solo la prima volta!
while (changed)
{
// get_relation()->zero(); // Azzera anche in runumerazione!
err = write(*_mask);
if (err == _isreinsert)
{

View File

@ -1,4 +1,4 @@
// $Id: relation.cpp,v 1.51 1995-07-06 15:22:26 guy Exp $
// $Id: relation.cpp,v 1.52 1995-07-07 14:43:41 guy Exp $
// relation.cpp
// fv 12/8/93
// relation class for isam files
@ -667,29 +667,25 @@ bool TRelation::isconsistent(bool reset)
int TRelation::write(bool force, TDate& atdate)
{
_errors = NOERR;
if (file(0).curr().empty())
return _errors; // *** no error returned **
// programmer must be aware
if ((_errors = file(0).write(atdate)) != NOERR)
_errors = file(0).write(atdate);
if (_errors != NOERR)
return _errors;
for (int i = 0; i < _reldefs.items(); i++)
{
TRelationdef& rd = reldef(i);
const int log = rd.num();
TRelationdef& rd = reldef(i);
TLocalisamfile& lf = file(rd.num());
if (!rd.write_enable() ||
(file(log).curr()).empty()) continue;
if (!rd.write_enable() || lf.curr().empty())
continue;
int res = file(log).write(atdate);
int res = lf.write(atdate);
if (force && res == _isreinsert)
res = file(log).rewrite(atdate);
if (_errors == NOERR) _errors = res;
res = lf.rewrite(atdate);
if (_errors == NOERR)
_errors = res;
}
return _errors;
}
@ -702,14 +698,14 @@ int TRelation::rewrite(bool force, TDate& atdate)
for (int i = 0; i < _reldefs.items(); i++)
{
TRelationdef& rd = reldef(i);
const int log = rd.num();
TLocalisamfile& lf = file(rd.num());
if (!rd.write_enable() ||
(file(log).curr()).empty()) continue;
if (!rd.write_enable() || lf.curr().empty())
continue;
int res = file(log).rewrite(atdate);
int res = lf.rewrite(atdate);
if (force && res == _iskeynotfound)
res = file(log).write(atdate);
res = lf.write(atdate);
if (_errors == NOERR) _errors = res;
}