isam.cpp Corretta buildkey coi booleani

maskfld.cpp
relation.cpp Corretta gestione cursori vuoti


git-svn-id: svn://10.65.10.50/trunk@2936 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1996-05-30 13:53:00 +00:00
parent 5a47a0786d
commit 7ae31d9d8a
3 changed files with 52 additions and 44 deletions

View File

@ -225,7 +225,6 @@ HIDDEN int CBuildKey(RecDes *recd, int numkey, RecType recin, char *key, bool b
if (numkey-- <= recd->NKeys)
{
int l = 0;
bool wasbool = FALSE;
for (int i = 0; i < recd->Ky[numkey].NkFields; i++)
{
const KeyDes& kd = recd->Ky[numkey];
@ -251,9 +250,14 @@ HIDDEN int CBuildKey(RecDes *recd, int numkey, RecType recin, char *key, bool b
return(_iskeylenerr);
}
if (f == _boolfld /* && build_x_cb */)
key[l] = *(recin + off) > ' ' ? 'T' : 'F';
{
const bool on = *(recin + off) > ' ' && strchr("STXY", *(recin + off)) != NULL;
key[l] = on ? 'T' : 'F';
}
else
{
strncpy((key + l), (recin + off), len);
}
if (recin[off] == '\0')
{
@ -274,7 +278,6 @@ HIDDEN int CBuildKey(RecDes *recd, int numkey, RecType recin, char *key, bool b
for (int i = l+len-1; i >= l; i--)
key[i] = toupper(key[i]);
wasbool = f == _boolfld;
l += len;
}
@ -2872,22 +2875,28 @@ void TRectype::put(const char* fieldname, bool val)
void TRectype::put(const char* fieldname, const char* val)
{
if (val == NULL || *val == '\0') // Da provare
const TFieldtypes ft = (TFieldtypes)CFieldType((char*) fieldname, rec_des());
if (val == NULL) val = "";
if (ft == _boolfld)
val = (*val > ' ' && strchr("STXY", toupper(*val)) != NULL) ? "T" : "F";
if (*val == '\0') // Da provare
{
TRecfield f(*this, fieldname);
if (*f.pos() == '\0') return;
}
if (CFieldType((char*) fieldname, rec_des()) == _datefld)
if (ft == _datefld)
{
TRecfield f(*this, fieldname);
f = val;
return;
}
if(CFieldType((char*) fieldname, rec_des()) == _memofld)
if(ft == _memofld)
{
// Qui registro il campo memo
CHECK( _memoinfo, "La struttura TMemo_info non è stata allocata!" );
@ -2895,18 +2904,7 @@ void TRectype::put(const char* fieldname, const char* val)
}
else
{
TString wval;
wval=val;
if (CFieldType((char*) fieldname,rec_des()) == _boolfld)
{
if (toupper(*val) == 'T' || toupper(*val) == 'Y'
|| toupper(*val) == 'S' || toupper(*val) == 'X')
wval="T";
else
wval="F";
}
if (CPutFieldBuff((char*) fieldname, rec_des(), (char*) (const char*)wval, _rec) == FIELDERR)
if (CPutFieldBuff((char*) fieldname, rec_des(), (char*)val, _rec) == FIELDERR)
UNKNOWN_FIELD(num(), fieldname);
}
setempty(FALSE);

View File

@ -2395,10 +2395,8 @@ const TBrowse* TEdit_field::parse_browse(TScanner& scanner) const
const int id = scanner.integer();
const TEdit_field& f = mask().efield(id);
const TBrowse* b = f.browse();
#ifdef DBG
if (b == NULL)
yesnofatal_box("La USE del campo %d e' nulla e non puo' essere copiata nel campo %d", id, dlg());
#endif
NFCHECK("La USE del campo %d e' nulla e non puo' essere copiata nel campo %d", id, dlg());
return b;
}
@ -2418,6 +2416,13 @@ bool TEdit_field::parse_item(TScanner& scanner)
if (scanner.key() == "FO") { _check = CHECK_REQUIRED; _forced = TRUE; } else
if (scanner.key() == "SE") _check = CHECK_SEARCH;
else _check = CHECK_NONE;
if (sheet())
{
#ifdef DBG
NFCHECK("Checktype inutile sul campo %d", dlg());
#endif
_check = CHECK_NONE;
}
return TRUE;
}
@ -2798,7 +2803,7 @@ bool TEdit_field::on_key(KEY key)
handler(K_TAB);
break;
case K_ENTER:
if (field() != NULL || mask().mode() == NO_MODE)
// if (field() != NULL || mask().mode() == NO_MODE)
{
bool ok = validate(K_ENTER); // Check validation expression
if (!ok)
@ -2808,28 +2813,25 @@ bool TEdit_field::on_key(KEY key)
return FALSE;
}
const bool query = mask().query_mode();
// check consistency
if (_browse)
if (!mask().query_mode() || forced())
{
if (sheet())
ok = query || sheet()->check(FINAL_CHECK);
else
ok = !(check_type() == CHECK_REQUIRED && empty());
// check consistency
if (ok && _browse)
{
ok = query || !(check_type() == CHECK_REQUIRED && empty());
if (ok && check_enabled() && vf != 21 && // 21 = NOT_EMPTY_CHECK_FIELD
(!query || forced()))
if (sheet())
ok = sheet()->check(FINAL_CHECK);
else
{
if (dirty()) ok = browse()->check(FINAL_CHECK); // Check consistency
else ok = browse()->empty_check();
if (ok && check_enabled() && vf != 21) // 21 = NOT_EMPTY_CHECK_FIELD
{
if (dirty()) ok = browse()->check(FINAL_CHECK); // Check consistency
else ok = browse()->empty_check();
}
}
}
if (!ok) return default_error_box();
}
else
ok = !required() || get().not_empty();
if (!ok) return default_error_box();
}
break;
case K_F9:

View File

@ -1164,8 +1164,16 @@ TRecnotype TCursor::read(TIsamop op, TReclock lockop, TDate& atdate)
if (approx && _if->file().status() == _iseof)
{
_pos = _totrec - 1;
readrec();
file().setstatus(_iseof);
if (_pos < 0)
{
file().zero();
file().setstatus(_isemptyfile);
}
else
{
readrec();
file().setstatus(_iseof);
}
return _pos;
}