Patch level : 2.1 nopatch

Files correlati     :
Ricompilazione Demo : [ ]
Commento            :

Stato dell'arte in conversione reports


git-svn-id: svn://10.65.10.50/trunk@12060 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2004-05-06 15:50:57 +00:00
parent 2b34881fe3
commit d0cad3f608
11 changed files with 305 additions and 156 deletions

View File

@ -1,3 +1,7 @@
: 2DROP ( n1 n2 -- )
DROP DROP
;
: 2DUP ( n1 n2 -- n1 n2 n1 n2 )
OVER OVER
;
@ -14,10 +18,15 @@
SWAP OVER
;
: +! ( n1 a1 -- )
DUP @ ROT + !
: +! ( a1 n1 -- ) \ Incrementa la variabile a1 di n1
DUP
IF
OVER @ + SWAP !
ELSE
2DROP
THEN
;
: INCR ( a1 -- )
1 SWAP +!
1 +!
;

View File

@ -87,7 +87,7 @@ bool TVariant::is_zero() const
case _datefld: return !as_date().ok();
case _longfld: return _ptr == NULL;
case _realfld: return as_real().is_zero();
case _alfafld: return real::is_null(as_string());
case _alfafld: return as_string().empty();
default: break;
}
return true;
@ -305,29 +305,24 @@ void TTable_names::fill()
int TTable_names::logic_num(const TString& name)
{
TString* str = (TString*)_names.objptr(name);
if (str == NULL && isalpha(name[0]))
if (isdigit(name[0]))
{
fill();
str = (TString*)_names.objptr(name);
}
int num = atoi(name);
if (name[name.len()-1] == '@')
num = -num;
return num;
}
if (name[0] == '%' && name.len() == 4)
return LF_TABCOM;
if (name.len() == 3)
return LF_TAB;
TString* str = (TString*)_names.objptr(name);
if (str == NULL)
{
if (isdigit(name[0]))
{
if (name.right(1) == "@")
add_file(-atoi(name), name);
else
add_file(atoi(name), name);
}
else
{
if (name[0] == '%')
add_file(LF_TABCOM, name); else
if (name.len() == 3)
add_file(LF_TAB, name);
}
fill();
str = (TString*)_names.objptr(name);
}
return str == NULL ? 0 : atoi(*str);
@ -628,16 +623,16 @@ const TVariant& TRecordset::get(const char* column_name) const
column_name++;
}
char* dot = strchr(column_name, ':');
if (dot != NULL)
char* colon = strchr(column_name, ':');
if (colon != NULL)
{
*dot = '\0';
*colon = '\0';
const int i = find_column(column_name);
*dot = ':';
*colon = ':';
if (i >= 0)
{
const TString& str = get(i).as_string();
TString subfield; subfield << (dot+1) << '=';
TString subfield; subfield << (colon+1) << '=';
int s = str.find(subfield);
if (s == 0 || (s > 0 && str[s-1] < ' '))
{
@ -1786,16 +1781,29 @@ TVariant& TISAM_recordset::get_tmp_var() const
return *var;
}
const TVariant& TISAM_recordset::get(int logic, const char* name) const
const TVariant& TISAM_recordset::get(int logic, const char* fldname) const
{
char* square = strchr(name, '[');
if (square != NULL) *square = '\0'; // Per il momento tronco il nome
TString80 name = fldname;
TString16 subfield;
int from = 1, to = 0;
const int open_bracket = name.find('[');
if (open_bracket > 0)
{
sscanf((const char*)name + open_bracket, "[%d,%d]", &from, &to);
name.cut(open_bracket);
}
const int colon = name.find(':');
if (colon > 0)
{
subfield = name.mid(colon+1);
name.cut(colon);
}
const TRectype& rec = _relation->curr(logic);
const TFieldtypes ft = rec.type(name);
if (square != NULL) *square = '['; // Ripristino il nome
if (ft == _nullfld)
return NULL_VARIANT;
@ -1810,13 +1818,22 @@ const TVariant& TISAM_recordset::get(int logic, const char* name) const
default : var.set(rec.get(name)); break;
}
if (square != NULL)
if (subfield.not_empty())
{
int from = 0, to = -1;
sscanf(square, "[%d,%d]", &from, &to);
var.set(var.as_string().sub(from-1, to));
subfield << '=';
const TString& str = var.as_string();
int s = str.find(subfield);
if (s == 0 || (s > 0 && str[s-1] < ' '))
{
s += subfield.len();
const int e = str.find('\n', s);
var.set(str.sub(s, e));
}
}
if (to >= from)
var.set(var.as_string().sub(from-1, to));
return var;
}

View File

@ -29,7 +29,7 @@ PAGE "Avanzate" -1 -1 50 16
MEMO F_INCLUDE 48 2
BEGIN
PROMPT 1 0 "Librerie (,) "
PROMPT 1 0 "Librerie (separate da ,) "
END
MEMO F_PRESCRIPT 48 6

View File

@ -673,13 +673,13 @@ TReport_section::~TReport_section()
// TReport_script
///////////////////////////////////////////////////////////
TString& TReport_script::translate_message() const
TString& TReport_script::translate_message(TReport& rep) const
{
TToken_string source(_src, '\n');
TToken_string line(256, '|');
TToken_string args(256, ',');
TString cmd, fld;
TString& alex = get_tmp_string();
TString cmd;
TString alex, empty_alex;
FOR_EACH_TOKEN(source, srcrow)
{
line = srcrow;
@ -691,36 +691,57 @@ TString& TReport_script::translate_message() const
{
line.ltrim(6);
line.trim();
alex << "#THIS @ 0= IF ";
}
FOR_EACH_TOKEN(line, tok)
{
const TFixed_string msg(tok);
const int comma = msg.find(',');
const int comma = msg.find(',');
if (comma > 0)
{
cmd = msg.left(comma);
cmd << msg.left(comma);
args = msg.mid(comma+1);
fld = args.get(0);
if (isdigit(fld[0]) && isdigit(fld[fld.len()-1]))
if (args[0] != '#') // Controlla se c'e' bisogno di un # all'inizio
{
fld.insert("#", 0);
args.add(fld, 0);
char type;
int level, id;
if (rep.parse_field(args.get(0), type, level, id) >= 2)
args.insert("#");
}
}
else
{
cmd = msg;
cmd << msg;
args.cut(0);
fld.cut(0);
}
alex << args << " MESSAGE_" << cmd << ' ';
if (cmd[0] != '_')
cmd.insert("_");
cmd.insert("MESSAGE");
if (rep.defined(cmd))
{
TString& alx = msg_empty ? empty_alex : alex;
alx << args << ' ' << cmd << ' ';
}
else
{
cmd << " ?";
error_box(cmd);
}
}
if (msg_empty)
alex << "THEN ";
}
return alex;
TString& src = get_tmp_string();
if (!empty_alex.blank())
{
src = "#THIS @ IF\n";
src << alex;
src << "\nELSE\n";
src << empty_alex;
src << "\nTHEN";
}
else
src = alex;
return src;
}
@ -745,7 +766,7 @@ bool TReport_script::compile(TReport& rep)
bool good = true;
if (_src.starts_with("MESSAGE "))
good = rep.compile(translate_message(), *_bc);
good = rep.compile(translate_message(rep), *_bc);
else
good = rep.compile(_src, *_bc);
_bc->set_name(_desc);
@ -1363,7 +1384,7 @@ void TReport_field::save(TXmlItem& root) const
};
switch (vertical_alignment())
{
case 'T': fld.SetAttr("valign", "top"); break;
case 'B': fld.SetAttr("valign", "bottom"); break;
case 'C': fld.SetAttr("valign", "center"); break;
default : break;
};
@ -1408,7 +1429,7 @@ bool TReport_field::load(const TXmlItem& fld)
set_back_color(get_col_attr(fld, "bg_color", COLOR_WHITE));
set_fore_color(get_col_attr(fld, "fg_color", COLOR_BLACK));
set_horizontal_alignment(get_chr_attr(fld, "align", 'L'));
set_vertical_alignment(get_chr_attr(fld, "valign", 'B'));
set_vertical_alignment(get_chr_attr(fld, "valign", 'T'));
set_picture(fld.GetAttr("text"));
set_codval(fld.GetAttr("codval"));
set_link(fld.GetAttr("link"));
@ -1787,7 +1808,13 @@ bool TReport::load(const char* fname)
_include = xml.GetAttr("libraries");
FOR_EACH_TOKEN(_include, lib)
include(lib);
{
TFilename libname = lib;
libname.trim();
if (libname.find('.') < 0)
libname.ext("alx");
include(libname);
}
_prescript.load(xml, "prescript");
_postscript.load(xml, "postscript");

View File

@ -111,7 +111,7 @@ class TReport_script : public TObject
protected:
void destroy();
TString& translate_message() const;
TString& translate_message(TReport& report) const;
void copy(const TReport_script& rs);
public:
@ -394,7 +394,6 @@ protected:
virtual bool set_usr_val(const TString& name, const TVariant& var);
KEY run_form(const TString& msk);
int parse_field(const char* code, char& type, int& level, int& id) const;
bool do_message(const TVariant& var, FLDMSG_FUNC msg, void* jolly);
void build_section_key(char type, int level, TString& key) const;
@ -452,6 +451,7 @@ public:
void set_curr_field(TReport_field* fld) { _curr_field = fld; }
TReport_field* curr_field() const { return _curr_field; }
int parse_field(const char* code, char& type, int& level, int& id) const;
TReport_field* field(const TString& code);
void destroy();

View File

@ -183,11 +183,9 @@ bool TPrint_preview_window::on_key(KEY k)
TPrint_preview_window::TPrint_preview_window(int x, int y, int dx, int dy, WINDOW parent,
TWindowed_field* owner, TPage_printer* printer)
: TField_window(x, y, dx, dy, parent, owner), _printer(printer),
_page(1), _last(0), _zoom(100)
_page(1), _last(0), _zoom(120)
{
RCT rct; xvt_vobj_get_client_rect(win(), &rct);
_zoom = 100 * rct.right / 800;
set_scroll_max(rct.right, rct.bottom);
}

View File

@ -102,9 +102,8 @@ enum AVM_opcode
avm_or, avm_over,
avm_perform, avm_pick, avm_plus_loop, avm_push,
avm_repeat, avm_rdrop, avm_rpeek, avm_rpush, avm_roll, avm_rot,
avm_store, avm_sub, avm_swap,
avm_strlen, avm_strmid, avm_store, avm_sub, avm_swap,
avm_then, avm_tok_fetch, avm_tok_store,
avm_strlen, avm_strmid,
avm_until, avm_usrword,
avm_variable,
avm_warm, avm_while,
@ -120,18 +119,19 @@ const char* AVM_TOKENS[avm_zzz+1] =
"=", ">", ">=", "<", "<=", "<>", "NULL=", "0=",
"DIV", "/", "DO", ".", "DROP", "DUP",
"ELSE",
"FALSE", "@", "FORGET",
"@", "FORGET",
"I", "IF", "INCLUDE",
"J",
"LOOP",
"MOD", "MON", "*",
"NEGATE",
"NEGATE", "NULL",
"OR", "OVER",
"PERFORM", "PICK", "+LOOP", "PUSH",
"REPEAT", "R>", "R@", ">R", "ROLL", "ROT",
"STRLEN", "STRMID", "!", "-", "SWAP",
"THEN", "TOK@", "TOK!", "TRUE",
"UNTIL", "#",
"THEN", "TOK@", "TOK!",
"UNTIL", "$USR$",
"VARIABLE",
"WARM", "WHILE"
};
@ -155,6 +155,7 @@ public:
TAVM_op(AVM_opcode o, const TString& str);
TAVM_op(AVM_opcode o, const real& num);
TAVM_op(AVM_opcode o, const long num);
TAVM_op(const TAVM_op& op);
TAVM_op(AVM_opcode o);
};
@ -173,21 +174,25 @@ void TAVM_op::set_auto_break(bool on)
TAVM_op::TAVM_op(AVM_opcode o, const TString& str)
: _op(o), _var(str), _break_pointer(false)
: _op(o), _var(str), _break_pointer(0)
{ }
TAVM_op::TAVM_op(AVM_opcode o, const real& num)
: _op(o), _var(num), _break_pointer(false)
: _op(o), _var(num), _break_pointer(0)
{ }
TAVM_op::TAVM_op(AVM_opcode o, const long num)
: _op(o), _var(num), _break_pointer(false)
: _op(o), _var(num), _break_pointer(0)
{ }
TAVM_op::TAVM_op(AVM_opcode o)
: _op(o), _break_pointer(false)
: _op(o), _break_pointer(0)
{ }
TAVM_op::TAVM_op(const TAVM_op& op) : _op(op._op), _var(op._var), _break_pointer(0)
{
}
///////////////////////////////////////////////////////////
// TAVM_monitor
///////////////////////////////////////////////////////////
@ -446,7 +451,7 @@ protected:
void do_call(const TString& func);
const TString_array& get_user_words();
int compile_user_word(const TString& n);
int compile_user_word(const char* n);
public:
const TString& get_last_error() const { return _last_error; }
@ -457,8 +462,8 @@ public:
bool do_include(const char* fname);
TVariant& do_fetch(const TString& name);
void do_store(const TString& name);
void set_interactive(bool inter) { _interactive = inter; }
bool defined(const char* w);
TAVM(TAlex_virtual_machine* vm);
virtual ~TAVM();
@ -547,7 +552,7 @@ const TString_array& TAVM::get_user_words()
return _user_words;
}
int TAVM::compile_user_word(const TString& w)
int TAVM::compile_user_word(const char* w)
{
const TString_array& uw = get_user_words();
const int i = uw.find(w);
@ -581,7 +586,7 @@ bool TAVM::compile(istream& instr, TBytecode& bytecode)
{
TBytecode* bc = new TBytecode;
bc->set_name(str);
_words.add(str, bc);
_words.add(str, bc, true);
compile(instr, *bc);
op = new TAVM_op(avm_nop);
}
@ -610,69 +615,78 @@ bool TAVM::compile(istream& instr, TBytecode& bytecode)
}
else
{
const AVM_opcode oc = token2opcode(str);
if (oc != avm_nop)
{
switch (oc)
{
case avm_else:
if (find_matching(bytecode, avm_if) < 0)
{
_last_error = "ELSE without matching IF";
log_error(_last_error);
return false;
}
op = new TAVM_op(oc);
break;
case avm_then:
if (find_matching(bytecode, avm_if, avm_else) < 0)
{
_last_error = "THEN without matching IF";
log_error(_last_error);
return false;
}
op = new TAVM_op(oc);
break;
case avm_loop:
case avm_plus_loop:
{
const do_pos = find_matching(bytecode, avm_do);
if (do_pos < 0)
{
_last_error.cut(0) << str << " without matching DO";
log_error(_last_error);
return false;
}
op = new TAVM_op(oc, do_pos);
}
break;
case avm_repeat:
case avm_until:
{
const int begin_pos = find_matching(bytecode, avm_begin);
if (begin_pos < 0)
{
_last_error.cut(0) << str << " without matching BEGIN";
log_error(_last_error);
return false;
}
find_matching(bytecode, avm_while);
op = new TAVM_op(oc, begin_pos);
}
break;
case avm_call_word:
op = new TAVM_op(oc, str);
break;
default:
op = new TAVM_op(oc);
break;
}
}
const int oc = compile_user_word(str);
if (oc > 0)
op = new TAVM_op(avm_usrword, oc);
else
{
const int oc = compile_user_word(str);
if (oc > 0)
op = new TAVM_op(avm_usrword, oc);
const AVM_opcode oc = token2opcode(str);
if (oc != avm_nop)
{
switch (oc)
{
case avm_else:
if (find_matching(bytecode, avm_if) < 0)
{
_last_error = "ELSE without matching IF";
log_error(_last_error);
return false;
}
op = new TAVM_op(oc);
break;
case avm_then:
if (find_matching(bytecode, avm_if, avm_else) < 0)
{
_last_error = "THEN without matching IF";
log_error(_last_error);
return false;
}
op = new TAVM_op(oc);
break;
case avm_loop:
case avm_plus_loop:
{
const do_pos = find_matching(bytecode, avm_do);
if (do_pos < 0)
{
_last_error.cut(0) << str << " without matching DO";
log_error(_last_error);
return false;
}
op = new TAVM_op(oc, do_pos);
}
break;
case avm_repeat:
case avm_until:
{
const int begin_pos = find_matching(bytecode, avm_begin);
if (begin_pos < 0)
{
_last_error.cut(0) << str << " without matching BEGIN";
log_error(_last_error);
return false;
}
find_matching(bytecode, avm_while);
op = new TAVM_op(oc, begin_pos);
}
break;
case avm_call_word:
{
const TBytecode* bc = (const TBytecode*)_words.objptr(str);
if (bc != NULL && bc->items() == 1)
{
const TAVM_op* inline_op = (const TAVM_op*)bc->objptr(0);
op = new TAVM_op(*inline_op);
}
else
op = new TAVM_op(oc, str);
}
break;
default:
op = new TAVM_op(oc);
break;
}
}
}
}
if (op != NULL)
@ -717,7 +731,7 @@ void TAVM::do_call(const TString& func)
}
else
{
_last_error = func; _last_error << " ???";
_last_error = func; _last_error << " ?";
log_error(_last_error);
_bc = NULL;
}
@ -772,6 +786,14 @@ void TAVM::do_store(const TString& name)
}
}
bool TAVM::defined(const char* name)
{
if (_words.objptr(name) != NULL)
return true;
return compile_user_word(name) > 0;
}
void TAVM::execute(const TAVM_op& op)
{
switch(op.op())
@ -1018,7 +1040,11 @@ bool TAVM::execute(const TBytecode& cmdline, ostream* outstr)
if (str == cmdline.name())
_bc = &cmdline;
else
{
_bc = (const TBytecode*)_words.objptr(str);
if (_bc == NULL)
break;
}
}
else
{
@ -1228,6 +1254,11 @@ bool TAlex_virtual_machine::include(const char* fname)
void TAlex_virtual_machine::set_interactive(bool inter)
{ avm().set_interactive(inter); }
bool TAlex_virtual_machine::defined(const char* name)
{
return avm().defined(name);
}
TAlex_virtual_machine::TAlex_virtual_machine() : _avm(NULL)
{
}

View File

@ -64,6 +64,7 @@ public:
void warm_restart();
void cold_restart();
void set_interactive(bool inter);
bool defined(const char* name);
TAlex_virtual_machine();
virtual ~TAlex_virtual_machine();

View File

@ -78,7 +78,19 @@ void TFormer_mask::parse_field_line(const TString& line, TReport_field& rf) cons
if (head.starts_with("FI"))
{
rf.set_field(head.get(1));
TString fld = head.get(1);
if (_doc)
{
if (fld.find("->") < 0)
fld.insert("33->");
if (fld.starts_with("33->"))
{
const TRectype doc(LF_DOC);
if (doc.type((const char*)fld + 4) == _nullfld)
fld.insert("G1:", 4);
}
}
rf.set_field(fld);
} else
if (head.starts_with("FL"))
{
@ -89,6 +101,10 @@ void TFormer_mask::parse_field_line(const TString& line, TReport_field& rf) cons
{
case 'D': rf.hide(); rf.deactivate(); break;
case 'H': rf.hide(); break;
case 'U':
if (rf.type() == 'V')
rf.set_type('P'); // Trasforma da Valuta a Prezzo
break;
default: break;
}
}
@ -133,9 +149,9 @@ void TFormer_mask::import_section(TScanner& scan, TReport_section& rs) const
const TString16 str_type = head.get(0);
char type = ' ';
if (str_type.starts_with("FI"))
type = 'I';
if (str_type.starts_with("ST"))
type = 'S';
type = 'I';
else
type = str_type[0];
if (type > ' ')
{
@ -156,6 +172,8 @@ void TFormer_mask::import_section(TScanner& scan, TReport_section& rs) const
else
cur_field->set_height(height);
}
if (strchr("NVP", type) != NULL)
cur_field->set_horizontal_alignment('R');
rs.add(cur_field);
}

View File

@ -6,6 +6,8 @@
: GET_POS.Y ( f1 -- n1 ) GET_POS NIP ;
: GET_SIZE.X ( f1 -- n1 ) GET_POS DROP ;
: GET_SIZE.Y ( f1 -- n1 ) GET_SIZE NIP ;
: GET_BOTTOM ( f1 -- n1 )
@ -47,17 +49,18 @@
: MESSAGE_ALIGN_CENTER ( f1 -- )
GET_BOTTOM \ Calcola fondo del campo f1
#THIS GET_BOTTOM \ Calcola fonp del campo corrente
#THIS GET_BOTTOM \ Calcola fondo del campo corrente
- 2 / \ Calcola offset verticale
OFFSET_FIELD_POS.Y \ Aggiorna posizione del campo corrente
;
\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
\ Implementazione dei vari messaggi standard
\ f1 campo o sezione del report
\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
: MESSAGE_ADD ( f1 -- )
#THIS @ SWAP !
#THIS @ +! \ Incrementa f1 col contenuto del campo corrente
;
: MESSAGE_ALIGN ( s1 -- )
@ -69,10 +72,34 @@
#THIS @ SWAP !
;
: MESSAGE_INC ( f1 -- )
DUP @ 1 + SWAP !
: MESSAGE_DEBUG
MON \ Attiva il fantastico debugger
;
: MESSAGE_DISABLE ( f1 -- )
DISABLE \ User defined word
;
: MESSAGE_ENABLE ( f1 -- )
ENABLE \ User defined word
;
: MESSAGE_HIDE ( f1 -- )
HIDE \ User defined word
;
: MESSAGE_INCR ( f1 -- )
INCR
;
: MESSAGE_PAGENO ( -- ) \ Numero di pagina corrente
#REPORT.PAGE @ THIS !
;
: MESSAGE_RESET ( f1 -- )
NULL SWAP !
;
: MESSAGE_SHOW ( f1 -- )
SHOW \ User defined word
;

View File

@ -1,9 +1,30 @@
: _DESCRIGA
#34->DESCR @
#DESCLUNGA @ IF
#34->DESCEST @
+
THEN
#THIS !
\ Messaggi specifici per stampa documenti
: MESSAGE_CLIENTE
DROP
;
: MESSAGE_DESCRIGA
#RDOC.DESCR @
#RDOC.DESCLUNGA @ IF
#RDOC.DESCEST @
+
THEN
#THIS !
;
: MESSAGE_DITTA
DROP
;
: MESSAGE_RIEPILOGOIVA
DROP
;
: MESSAGE_SCADENZE
DROP
;
: MESSAGE_TOTIMPONIBILI
DROP
;