Corrette ricerche e caricamneto funzioni9 utente

git-svn-id: svn://10.65.10.50/trunk@3477 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1996-09-02 14:00:46 +00:00
parent c4c17f1e9a
commit 96485b6fc6

View File

@ -69,19 +69,16 @@ void TTable_expression::load_table(bool force)
n = expr.get("CODTAB"); n = expr.get("CODTAB");
e = expr.get("S1"); e = expr.get("S1");
e << expr.get("S2"); e << expr.get("S2");
const TTypeexp t = expr.get_bool("B0") ? _numexpr : _strexpr; const TTypeexp t = expr.get_bool("B0") ? _strexpr : _numexpr;
TTable_expression* te = new TTable_expression; TTable_expression* te = new TTable_expression;
if (te->set(e, t))
{
THash_object* o = new THash_object(n, te); THash_object* o = new THash_object(n, te);
_expr.add(o); const int index = _expr.add(o);
} if (!te->set(e, t))
else
{ {
te->error_box("La funzione %s contiene un simbolo errato: %s", te->error_box("La funzione %s contiene un simbolo errato: %s",
(const char*)n, te->last_token()); (const char*)n, te->last_token());
delete te; te->set("", t);
} }
} }
} }
@ -171,17 +168,18 @@ int TTable_expression::name2index(const char* name) const
if (_expr.items() == 0) if (_expr.items() == 0)
load_table(); load_table();
TString code(name); code.upper();
for (int index = _expr.items()-1; index >= 0; index--) for (int index = _expr.items()-1; index >= 0; index--)
{ {
const THash_object& h = (const THash_object&)_expr[index]; const THash_object& h = (const THash_object&)_expr[index];
if (h.key() == name) if (h.key() == code)
break; break;
} }
if (index < 0) if (index < 0)
{ {
TTable expr("%FRM"); TTable expr("%FRM");
expr.put("CODTAB", name); expr.put("CODTAB", code);
if (expr.read() == NOERR) if (expr.read() == NOERR)
{ {
TString e(127); TString e(127);
@ -190,7 +188,7 @@ int TTable_expression::name2index(const char* name) const
TTable_expression* te = new TTable_expression; TTable_expression* te = new TTable_expression;
if (te->set(e, t)) if (te->set(e, t))
{ {
THash_object* o = new THash_object(name, te); THash_object* o = new THash_object(code, te);
index = _expr.add(o); index = _expr.add(o);
} }
else else
@ -587,10 +585,10 @@ TCursor& TRicalcolo_mask::create_cursor()
bool TRicalcolo_mask::file_handler(TMask_field& f, KEY k) bool TRicalcolo_mask::file_handler(TMask_field& f, KEY k)
{ {
TRicalcolo_mask& m = (TRicalcolo_mask&)f.mask(); TRicalcolo_mask& m = (TRicalcolo_mask&)f.mask();
if (k == K_SPACE) if (k == K_SPACE && m.is_running())
{ {
const int n = atoi(f.get()); const int n = atoi(f.get());
if (n != m._cur_file || !m.is_running()) if (n != m._cur_file)
{ {
m._cur_file = n; m._cur_file = n;
const RecDes* rd = m.get_rec_des(); const RecDes* rd = m.get_rec_des();
@ -607,10 +605,9 @@ bool TRicalcolo_mask::file_handler(TMask_field& f, KEY k)
tmp.format("Chiave %d", k); tmp.format("Chiave %d", k);
values.add(tmp); values.add(tmp);
} }
TList_field& lk = (TList_field&)m.field(F_KEY); TList_field& lk = (TList_field&)m.field(F_KEY);
lk.replace_items(codes, values); lk.replace_items(codes, values);
if (atoi(lk.get()) != 0)
lk.reset();
} }
} }
return TRUE; return TRUE;
@ -621,12 +618,14 @@ bool TRicalcolo_mask::key_handler(TMask_field& f, KEY k)
if (k == K_SPACE) if (k == K_SPACE)
{ {
TRicalcolo_mask& m = (TRicalcolo_mask&)f.mask(); TRicalcolo_mask& m = (TRicalcolo_mask&)f.mask();
TSheet_field& sheet = (TSheet_field&)m.field(F_FIELDS);
if (m.is_running() || sheet.items() == 0)
{
const int cur_key = atoi(f.get()); const int cur_key = atoi(f.get());
TToken_string& key_expr = m.get_key_expr(cur_key); TToken_string& key_expr = m.get_key_expr(cur_key);
const bool empty = key_expr.empty_items(); const bool empty = key_expr.empty_items();
int first_enabled = 0; int first_enabled = 0;
TSheet_field& sheet = (TSheet_field&)m.field(F_FIELDS);
TString_array& sa = sheet.rows_array(); TString_array& sa = sheet.rows_array();
sa.destroy(); sa.destroy();
if (empty) if (empty)
@ -637,7 +636,7 @@ bool TRicalcolo_mask::key_handler(TMask_field& f, KEY k)
else else
{ {
TRelation_description& des = m.get_des(); TRelation_description& des = m.get_des();
for (TString field = key_expr.get(0); field.not_empty(); field = key_expr.get()) for (TString field = key_expr.get(0); !field.blank(); field = key_expr.get())
{ {
const int r = sa.add(field); const int r = sa.add(field);
sa.row(r).add(des.get_field_description(field), F_DESCR-F_FIELD); sa.row(r).add(des.get_field_description(field), F_DESCR-F_FIELD);
@ -657,6 +656,7 @@ bool TRicalcolo_mask::key_handler(TMask_field& f, KEY k)
sheet.force_update(); sheet.force_update();
} }
}
return TRUE; return TRUE;
} }