Patch level : 10.0
Files correlati : ba1.exe Ricompilazione Demo : [ ] Commento : Reso impossibile importare per errore file di testo a lunghezza fissa git-svn-id: svn://10.65.10.50/trunk@19484 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
0f6620e80f
commit
5d1297ef53
@ -426,7 +426,7 @@ public:
|
||||
const TString& get_last_error() const { return _last_error; }
|
||||
|
||||
bool compile(istream& instr, TBytecode& bc);
|
||||
bool execute(const TBytecode& bc);
|
||||
bool execute(const TBytecode& bc, ostream* outstr);
|
||||
void do_restart(bool cold);
|
||||
bool do_include(const char* fname);
|
||||
void do_fetch(const TString& name);
|
||||
@ -444,10 +444,8 @@ void TAVM::log_error(const char* str)
|
||||
_last_error = str;
|
||||
if (_interactive)
|
||||
error_box(str);
|
||||
#ifdef DBG
|
||||
else
|
||||
statbar_set_title(TASK_WIN, str);
|
||||
#endif
|
||||
xvtil_popup_error(str);
|
||||
}
|
||||
|
||||
bool TAVM::get_token(istream& instr, TString& str) const
|
||||
@ -735,7 +733,7 @@ bool TAVM::do_include(const char* fname)
|
||||
ifstream inf(name);
|
||||
ok = compile(inf, bc);
|
||||
if (ok)
|
||||
execute(bc);
|
||||
execute(bc, NULL);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
@ -856,7 +854,9 @@ void TAVM::execute(const TAVM_op& op)
|
||||
break;
|
||||
case avm_dot:
|
||||
if (_outstr != NULL)
|
||||
*_outstr << _stack.pop().as_string();
|
||||
*_outstr << _stack.pop().as_string();
|
||||
else
|
||||
xvtil_popup_message(_stack.pop().as_string());
|
||||
break;
|
||||
case avm_drop:
|
||||
if (!_stack.drop())
|
||||
@ -1040,7 +1040,7 @@ void TAVM::execute(const TAVM_op& op)
|
||||
}
|
||||
}
|
||||
|
||||
bool TAVM::execute(const TBytecode& cmdline)
|
||||
bool TAVM::execute(const TBytecode& cmdline, ostream* outstr)
|
||||
{
|
||||
const TBytecode* old_bc = _bc;
|
||||
const int old_ip = _ip;
|
||||
@ -1050,6 +1050,7 @@ bool TAVM::execute(const TBytecode& cmdline)
|
||||
_rstack.reset();
|
||||
_bc = &cmdline;
|
||||
_ip = 0;
|
||||
_outstr = outstr;
|
||||
|
||||
while (_bc != NULL)
|
||||
{
|
||||
@ -1122,6 +1123,7 @@ bool TAVM::execute(const TBytecode& cmdline)
|
||||
//const bool ok = _bc != NULL; // Not aborted
|
||||
_bc = old_bc;
|
||||
_ip = old_ip;
|
||||
_outstr = NULL;
|
||||
|
||||
return !aborted;
|
||||
}
|
||||
@ -1178,9 +1180,9 @@ bool TAlex_virtual_machine::compile(istream& instr, TBytecode& bc)
|
||||
return avm().compile(instr, bc);
|
||||
}
|
||||
|
||||
bool TAlex_virtual_machine::execute(const TBytecode& bc)
|
||||
bool TAlex_virtual_machine::execute(const TBytecode& bc, ostream* out)
|
||||
{
|
||||
return avm().execute(bc);
|
||||
return avm().execute(bc, out);
|
||||
}
|
||||
|
||||
bool TAlex_virtual_machine::compile(const char* cmd, TBytecode& bc)
|
||||
|
@ -42,7 +42,7 @@ public:
|
||||
|
||||
bool compile(istream& instr, TBytecode& bc);
|
||||
bool compile(const char* cmd, TBytecode& bc);
|
||||
bool execute(const TBytecode& bc);
|
||||
bool execute(const TBytecode& bc, ostream* out = NULL);
|
||||
bool include(const char* fname);
|
||||
|
||||
void warm_restart();
|
||||
|
@ -32,7 +32,7 @@ bool error_box(
|
||||
// e l'icona punto esclamativo.
|
||||
{
|
||||
buildmsg();
|
||||
xvt_dm_post_error(msg);
|
||||
xvt_dm_popup_error(msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ bool warning_box(
|
||||
// e l'icona punto di domanda.
|
||||
{
|
||||
buildmsg();
|
||||
xvt_dm_post_warning(msg);
|
||||
xvt_dm_popup_warning(msg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ bool message_box(
|
||||
// e l'icona informazioni.
|
||||
{
|
||||
buildmsg();
|
||||
xvt_dm_post_message(msg);
|
||||
xvt_dm_popup_message(msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -156,6 +156,11 @@ int yesnocancel_box(
|
||||
return r == RESP_DEFAULT ? K_YES : (r == RESP_2 ? K_NO : K_ESC);
|
||||
}
|
||||
|
||||
bool cantread_box(const char* filename)
|
||||
{
|
||||
return error_box("Impossibile leggere '%s'", filename);
|
||||
}
|
||||
|
||||
// @doc EXTERNAL
|
||||
// @msg __trace | Permette di mandare dei messaggi nel file trace.log
|
||||
bool __trace(
|
||||
|
@ -17,6 +17,7 @@ extern "C" {
|
||||
bool yesno_box(const char* fmt, ...);
|
||||
int yesnocancel_box(const char* fmt, ...);
|
||||
bool yesnofatal_box(const char* fmt, ...);
|
||||
bool cantread_box(const char* filename);
|
||||
bool __trace(const char* fmt, ...);
|
||||
bool __tracemem(const char* fmt);
|
||||
#ifdef __cplusplus
|
||||
|
102
include/isam.cpp
102
include/isam.cpp
@ -2318,12 +2318,12 @@ int TSystemisamfile::pack(bool vis, bool ask)
|
||||
// di errore generato (vedi <t TIsamerr>).
|
||||
int TSystemisamfile::load(
|
||||
const char* from, // @parm Nome del file da importare
|
||||
char fs, // @parm Carattere separatore di campo (default <pipe>)
|
||||
char fd, // @parm Carattere delimitatore di campi (default '\\0')
|
||||
char rs, // @parm Carattere separatore di record (default '\\n')
|
||||
bool vis, // @parm Indica se visualizzare lo stato dell'operazione (default TRUE)
|
||||
bool extended, // @parm Indica se interpretare alcune stringhe come macro (default FALSE)
|
||||
bool indexed) // @parm Indica se indicizzare subito o alla fine
|
||||
char fs, // @parm Carattere separatore di campo (default <pipe>)
|
||||
char fd, // @parm Carattere delimitatore di campi (default '\\0')
|
||||
char rs, // @parm Carattere separatore di record (default '\\n')
|
||||
bool vis, // @parm Indica se visualizzare lo stato dell'operazione (default TRUE)
|
||||
bool extended, // @parm Indica se interpretare alcune stringhe come macro (default FALSE)
|
||||
bool indexed) // @parm Indica se indicizzare subito o alla fine
|
||||
|
||||
// @comm Se <p extended> e' TRUE e trova alcune stringhe col formato %stringa% (es. %frm%)
|
||||
// ne sostituisce i valori (es. ditta corrente).
|
||||
@ -2332,10 +2332,10 @@ int TSystemisamfile::load(
|
||||
|
||||
{
|
||||
int err=NOERR;
|
||||
FILE* fl = fopen(from, "r");
|
||||
FILE* fl = NULL; fopen_s(&fl, from, "r");
|
||||
if (fl == NULL)
|
||||
{
|
||||
error_box("Impossibile aprire il file %s",from);
|
||||
cantread_box(from);
|
||||
setstatus(2);
|
||||
return 2;
|
||||
}
|
||||
@ -2344,7 +2344,7 @@ int TSystemisamfile::load(
|
||||
|
||||
if (extended)
|
||||
{
|
||||
TDate d(TODAY);
|
||||
const TDate d(TODAY);
|
||||
year.format("%04d", d.year());
|
||||
firm.format("%05ld", prefix().get_codditta());
|
||||
attprev = cache().get(LF_NDITTE, firm, NDT_CODATTPREV);
|
||||
@ -2357,7 +2357,8 @@ int TSystemisamfile::load(
|
||||
err = _open_ex(_excllock, indexed);
|
||||
if (err != NOERR)
|
||||
{
|
||||
error_box("Impossibile aprire il file %d", _logicnum);
|
||||
TString msg; msg << _logicnum << " (" << name() << ')';
|
||||
cantread_box(msg);
|
||||
return err;
|
||||
}
|
||||
|
||||
@ -2365,8 +2366,9 @@ int TSystemisamfile::load(
|
||||
const bool fixedlen = (fs == '\0');
|
||||
TToken_string s(1024, fixedlen ? char(255) : fs);
|
||||
int nflds = curr().items();
|
||||
TString_array fld(nflds);
|
||||
int len[MaxFields];
|
||||
TString_array fld(nflds);
|
||||
TPointer_array fldlen(nflds);
|
||||
int reclen = 0;
|
||||
TString sfd(3);
|
||||
TString s1(256);
|
||||
bool lcf = FALSE;
|
||||
@ -2380,23 +2382,14 @@ int TSystemisamfile::load(
|
||||
{
|
||||
key = f.token().left(equal);
|
||||
key.trim();
|
||||
/* if (key == "Version")
|
||||
{
|
||||
const unsigned int level = atoi(f.token().mid(equal+1));
|
||||
if (level > prefix().filelevel())
|
||||
{
|
||||
const unsigned int stdlevel = prefix().get_stdlevel();
|
||||
error_box(FR("L'archivio %s e' stato generato con gli archivi di livello %ld%/%ld.\n Il livello attuale e' %ld/%ld.\n Convertire gli archivi e ripetere l' operazione."),
|
||||
from, level/100, level%100, stdlevel/100, stdlevel%100);
|
||||
}
|
||||
lcf = getlcf(level);
|
||||
} else*/
|
||||
if (key == "File")
|
||||
{
|
||||
const int logic = atoi(f.token().mid(equal+1));
|
||||
if (logic != num())
|
||||
error_box("L'archivio %s e' stato generato dal file %d",
|
||||
from, logic);
|
||||
{
|
||||
error_box("L'archivio %s e' stato generato dal file %d", from, logic);
|
||||
return _isbadtrc;
|
||||
}
|
||||
} else
|
||||
if (key == "Fields")
|
||||
{
|
||||
@ -2406,8 +2399,9 @@ int TSystemisamfile::load(
|
||||
{
|
||||
wfd = fd; wfd.strip_spaces();
|
||||
fld.add(wfd.get(0));
|
||||
len[nflds] = wfd.get_int();
|
||||
nflds++;
|
||||
const int l = wfd.get_int();
|
||||
fldlen.add_long(l, nflds++);
|
||||
reclen += l;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2419,8 +2413,9 @@ int TSystemisamfile::load(
|
||||
for (int j = 0; j < nflds; j++)
|
||||
{
|
||||
fld.add(curr().fieldname(j), j);
|
||||
const TString & wfld = (const TString & ) fld[j];
|
||||
len[j] = (curr().type(wfld) == _datefld) ? 10 : curr().length(wfld);
|
||||
const TString& wfld = fld.row(j);
|
||||
const int l = (curr().type(wfld) == _datefld) ? 10 : curr().length(wfld);
|
||||
fldlen.add_long(l, j);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2439,11 +2434,17 @@ int TSystemisamfile::load(
|
||||
const char* const fmt = FR("Importazione archivio %d da %s\n%6ld records %6ld errori - %3d");
|
||||
|
||||
s1.format(fmt, _logicnum, from, r, e, last);
|
||||
TProgind p(nitems, s1, TRUE, TRUE, 70);
|
||||
TProgind p(nitems, s1);
|
||||
|
||||
long pos = 16*nflds;
|
||||
for (s = f.line(); s.not_empty() && !p.iscancelled(); s = f.line())
|
||||
while(!f.eof())
|
||||
{
|
||||
if (fixedlen)
|
||||
f.getline(s.get_buffer(reclen+2), reclen+2);
|
||||
else
|
||||
s = f.line();
|
||||
if (s.empty())
|
||||
break;
|
||||
|
||||
if (extended)
|
||||
{
|
||||
int p, i;
|
||||
@ -2461,18 +2462,25 @@ int TSystemisamfile::load(
|
||||
p.set_text(s1);
|
||||
}
|
||||
|
||||
pos += s.len()+2;
|
||||
p.setstatus(pos);
|
||||
if (!p.setstatus(f.tellg()))
|
||||
break;
|
||||
|
||||
zero();
|
||||
if (fixedlen)
|
||||
{
|
||||
if (s.len() < reclen)
|
||||
{
|
||||
error_box(FR("Record di lunghezza errata: %d invece di %d"), s.len(), reclen);
|
||||
break;
|
||||
}
|
||||
int pos = 0;
|
||||
for (int j = 0; j < nflds; j++)
|
||||
{
|
||||
s1 = s.mid(pos,len[j]);
|
||||
const int l = fldlen.get_int(j);
|
||||
s1 = s.mid(pos, l);
|
||||
s1.rtrim();
|
||||
put((const TString&) fld[j], s1);
|
||||
pos += len[j];
|
||||
put(fld.row(j), s1);
|
||||
pos += l;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -2574,7 +2582,7 @@ int TSystemisamfile::overwrite(
|
||||
TString_array fld(nflds);
|
||||
TString_array keyfld(nflds);
|
||||
TAssoc_array vals;
|
||||
int len[MaxFields];
|
||||
int len[MaxFields];
|
||||
TString sfd(3);
|
||||
TString s1(256);
|
||||
bool lcf = FALSE;
|
||||
@ -2614,8 +2622,7 @@ int TSystemisamfile::overwrite(
|
||||
{
|
||||
wfd = fd; wfd.strip_spaces();
|
||||
fld.add(wfd.get(0));
|
||||
len[nflds] = wfd.get_int();
|
||||
nflds++;
|
||||
len[nflds++] = wfd.get_int();
|
||||
}
|
||||
const RecDes& rd = curr().rec_des();
|
||||
const KeyDes& kd = rd.Ky[0];
|
||||
@ -2636,8 +2643,14 @@ int TSystemisamfile::overwrite(
|
||||
for (int j = 0; j < nflds; j++)
|
||||
{
|
||||
fld.add(curr().fieldname(j), j);
|
||||
const TString & wfld = (const TString & ) fld[j];
|
||||
len[j] = (curr().type(wfld) == _datefld) ? 10 : curr().length(wfld);
|
||||
const TString & wfld = fld.row(j);
|
||||
int l = 0;
|
||||
switch (curr().type(wfld))
|
||||
{
|
||||
case _datefld: l = 10; break;
|
||||
default : l = curr().length(wfld); break;
|
||||
}
|
||||
len[j] = l;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2795,7 +2808,10 @@ int TSystemisamfile::dump(
|
||||
t == _wordfld || t == _intzerofld || t == _longzerofld);
|
||||
len[j] = (t == _datefld) ? 10 : curr().length(wfld);
|
||||
if (fixedlen && t == _memofld)
|
||||
return error_box(TR("Non e' possibile scaricare a lunghezza fissa un file con campi memo"));
|
||||
{
|
||||
error_box(TR("Non e' possibile scaricare a lunghezza fissa un file con campi memo"));
|
||||
return _isbadtrc;
|
||||
}
|
||||
}
|
||||
TRecnotype i = 0;
|
||||
const TRecnotype nitems = items();
|
||||
|
@ -1866,9 +1866,9 @@ void TMask::on_idle()
|
||||
set_focus();
|
||||
switch(_error_severity)
|
||||
{
|
||||
case 2: xvt_dm_popup_warning(_error_message); break;
|
||||
case 3: xvt_dm_popup_error (_error_message); break;
|
||||
default: xvt_dm_popup_message(_error_message); break;
|
||||
case 2: warning_box(_error_message); break;
|
||||
case 3: error_box(_error_message); break;
|
||||
default: message_box(_error_message); break;
|
||||
}
|
||||
_error_severity = 0;
|
||||
}
|
||||
|
@ -987,8 +987,11 @@ FILE* TCursor::open_index(
|
||||
if (_indexname != _last_name || create)
|
||||
{
|
||||
if (_last_ndx != NULL)
|
||||
{
|
||||
fclose(_last_ndx);
|
||||
_last_ndx = fopen(_indexname, create ? "wb" : "rb");
|
||||
_last_ndx = NULL;
|
||||
}
|
||||
fopen_s(&_last_ndx, _indexname, create ? "wb" : "rb"); // Secured _last_ndx = fopen(_indexname, create ? "wb" : "rb");
|
||||
if (_last_ndx == NULL)
|
||||
fatal_box("Can't use cursor index for file %d: '%s'\n",
|
||||
file().num(), (const char*)_indexname);
|
||||
|
@ -990,14 +990,17 @@ bool TReport_script::execute(TReport& rep)
|
||||
return good;
|
||||
}
|
||||
|
||||
bool TReport_script::execute(TReport_field& rf)
|
||||
bool TReport_script::execute(TReport_field& rf, ostream* outstr)
|
||||
{
|
||||
bool good = true;
|
||||
if (ok())
|
||||
{
|
||||
TReport& rep = rf.section().report();
|
||||
rep.set_curr_field(&rf);
|
||||
good = execute(rep);
|
||||
if (_bc == NULL)
|
||||
good = compile(rep);
|
||||
if (good)
|
||||
good = rep.execute(*_bc, outstr);
|
||||
}
|
||||
return good;
|
||||
}
|
||||
@ -1284,12 +1287,21 @@ bool TReport_field::execute_prescript()
|
||||
bool ok = true;
|
||||
if (!draw_deactivated())
|
||||
{
|
||||
ok = _prescript.execute(*this);
|
||||
TString256 tmp;
|
||||
ostrstream outstr(tmp.get_buffer(), tmp.size()-1);
|
||||
|
||||
ok = _prescript.execute(*this, &outstr);
|
||||
if (ok && type() == 'A')
|
||||
{
|
||||
TReport_array_item* item = get_array_item();
|
||||
if (item != NULL)
|
||||
ok = item->_script.execute(*this);
|
||||
ok = item->_script.execute(*this, &outstr);
|
||||
}
|
||||
|
||||
if (ok && tmp.not_empty())
|
||||
{
|
||||
tmp.cut(256);
|
||||
set(tmp);
|
||||
}
|
||||
}
|
||||
return ok;
|
||||
@ -1297,7 +1309,7 @@ bool TReport_field::execute_prescript()
|
||||
|
||||
bool TReport_field::execute_postscript()
|
||||
{
|
||||
return draw_deactivated() || _postscript.execute(*this);
|
||||
return draw_deactivated() || _postscript.execute(*this, NULL);
|
||||
}
|
||||
|
||||
COLOR TReport_field::link_color() const
|
||||
|
@ -128,7 +128,7 @@ public:
|
||||
|
||||
bool compile(TReport& report);
|
||||
bool execute(TReport& report);
|
||||
bool execute(TReport_field& rf);
|
||||
bool execute(TReport_field& rf, ostream* outstr);
|
||||
|
||||
void save(TXmlItem& root, const char* tag) const;
|
||||
bool load(const TXmlItem& root, const char* tag);
|
||||
|
@ -608,7 +608,7 @@ bool is_power_station()
|
||||
|
||||
bool is_power_reseller(bool power_user_only)
|
||||
{
|
||||
bool yes = xvt_sys_get_oem_int("OEM", -1);
|
||||
bool yes = xvt_sys_get_oem_int("OEM", -1) == 0;
|
||||
if (yes && power_user_only)
|
||||
yes = is_power_station();
|
||||
return yes;
|
||||
|
@ -2729,7 +2729,7 @@ long TBrowsefile_field::set_text(const char* file, const char* line)
|
||||
{
|
||||
long ret = -1;
|
||||
|
||||
FILE* instr = fopen(file, "r");
|
||||
FILE* instr = NULL; fopen_s(&instr, file, "r"); // Secured FILE* instr = fopen(file, "r");
|
||||
if (instr != NULL)
|
||||
{
|
||||
TWait_cursor hourglass;
|
||||
|
@ -652,6 +652,33 @@ int xvtil_statbar_height()
|
||||
return h;
|
||||
}
|
||||
|
||||
static bool xvtil_popup_something(int severity, const char* msg)
|
||||
{
|
||||
if (is_power_reseller())
|
||||
{
|
||||
switch (severity)
|
||||
{
|
||||
case 1: xvt_dm_popup_warning(msg); break;
|
||||
case 2: xvt_dm_popup_error(msg); break;
|
||||
default: xvt_dm_popup_message(msg); break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
beep(severity);
|
||||
xvtil_statbar_set(msg);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool xvtil_popup_message(const char* msg)
|
||||
{ return xvtil_popup_something(0, msg); }
|
||||
|
||||
bool xvtil_popup_warning(const char* msg)
|
||||
{ return xvtil_popup_something(1, msg); }
|
||||
|
||||
bool xvtil_popup_error(const char* msg)
|
||||
{ return xvtil_popup_something(2, msg); }
|
||||
|
||||
///////////////////////////////////////////////////////////
|
||||
// Test menu
|
||||
|
@ -39,6 +39,10 @@ void xvtil_statbar_refresh();
|
||||
void xvtil_statbar_destroy();
|
||||
int xvtil_statbar_height();
|
||||
|
||||
bool xvtil_popup_message(const char* msg);
|
||||
bool xvtil_popup_warning(const char* msg);
|
||||
bool xvtil_popup_error(const char* msg);
|
||||
|
||||
void beep(int severity = 0);
|
||||
void do_events();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user