From 7ae31d9d8aaa667ae97f7b35f517734f2a9f1339 Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 30 May 1996 13:53:00 +0000 Subject: [PATCH] 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 --- include/isam.cpp | 38 +++++++++++++++++------------------- include/maskfld.cpp | 46 +++++++++++++++++++++++--------------------- include/relation.cpp | 12 ++++++++++-- 3 files changed, 52 insertions(+), 44 deletions(-) diff --git a/include/isam.cpp b/include/isam.cpp index 9ea45862f..b89dddb93 100755 --- a/include/isam.cpp +++ b/include/isam.cpp @@ -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'; - else + { + 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) +{ + const TFieldtypes ft = (TFieldtypes)CFieldType((char*) fieldname, rec_des()); + + if (val == NULL) val = ""; -{ - if (val == NULL || *val == '\0') // Da provare + 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); diff --git a/include/maskfld.cpp b/include/maskfld.cpp index b1cb529af..fd988b7fe 100755 --- a/include/maskfld.cpp +++ b/include/maskfld.cpp @@ -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; } @@ -2411,13 +2409,20 @@ bool TEdit_field::parse_item(TScanner& scanner) } if (scanner.key() == "CH") - { + { scanner.pop(); if (scanner.key() == "NO") _check = CHECK_NORMAL; else if (scanner.key() == "RE") _check = CHECK_REQUIRED; else 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(); + } } } - } - else - ok = !required() || get().not_empty(); - if (!ok) return default_error_box(); - + if (!ok) return default_error_box(); + } } break; case K_F9: diff --git a/include/relation.cpp b/include/relation.cpp index a73cc70e1..59f6aca13 100755 --- a/include/relation.cpp +++ b/include/relation.cpp @@ -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; }