Patch level : 10.0

Files correlati     : report.alx
Ricompilazione Demo : [ ]
Commento            :
Corretto messaggio di incremento importi


git-svn-id: svn://10.65.10.50/trunk@20344 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 2010-04-15 14:49:40 +00:00
parent af646cfa73
commit d08c97ed08
5 changed files with 139 additions and 105 deletions

View File

@ -32,7 +32,7 @@ enum AVM_opcode
avm_negate, avm_null, avm_negate, avm_null,
avm_or, avm_over, avm_or, avm_over,
avm_perform, avm_pick, avm_plus_loop, avm_plus_store, avm_push, avm_perform, avm_pick, avm_plus_loop, avm_plus_store, avm_push,
avm_repeat, avm_rdrop, avm_rpeek, avm_rpush, avm_roll, avm_rot, avm_round, avm_repeat, avm_rpop, avm_rpeek, avm_rpush, avm_roll, avm_rot, avm_round,
avm_strfind, avm_strlen, avm_strmid, avm_strtok_fetch, avm_strtok_add, avm_strfind, avm_strlen, avm_strmid, avm_strtok_fetch, avm_strtok_add,
avm_store, avm_sp, avm_sub, avm_swap, avm_store, avm_sp, avm_sub, avm_swap,
avm_then, avm_trunc, avm_then, avm_trunc,
@ -193,8 +193,7 @@ void TAVM_list_window::update()
if (op.has_break()) if (op.has_break())
printat(4, y, "<"); printat(4, y, "<");
if (co == avm_else || co == avm_then || if (co == avm_else || co == avm_then || co == avm_loop || co == avm_plus_loop ||
co == avm_loop || co == avm_plus_loop ||
co == avm_repeat || co == avm_until || co == avm_while) co == avm_repeat || co == avm_until || co == avm_while)
tab -= 2; tab -= 2;
if (co == avm_push) if (co == avm_push)
@ -225,8 +224,7 @@ void TAVM_list_window::update()
str << " (" << var.as_string() << ')'; str << " (" << var.as_string() << ')';
} }
printat(tab, y, str); printat(tab, y, str);
if (co == avm_if || co == avm_else || if (co == avm_if || co == avm_else || co == avm_do || co == avm_begin || co == avm_while)
co == avm_do || co == avm_begin || co == avm_while)
tab += 2; tab += 2;
} }
} }
@ -325,7 +323,6 @@ class TAVM_monitor : public TAutomask
protected: protected:
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly); virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
virtual bool on_key(KEY k);
public: public:
void set_ignore_mon(bool im) { _ignore_mon = im; } void set_ignore_mon(bool im) { _ignore_mon = im; }
@ -339,32 +336,25 @@ public:
bool TAVM_monitor::on_field_event(TOperable_field& o, TField_event e, long jolly) bool TAVM_monitor::on_field_event(TOperable_field& o, TField_event e, long jolly)
{ {
return true; switch (o.dlg())
}
bool TAVM_monitor::on_key(KEY k)
{ {
switch (k) case DLG_CANCEL:
{ if (e == fe_button)
case K_F9:
set_ignore_mon(true); set_ignore_mon(true);
case K_F10: break;
case K_F11:
stop_run(k);
return true;
default: break; default: break;
} }
return TAutomask::on_key(k); return true;
} }
TAVM_monitor::TAVM_monitor() : TAutomask("Monitor", 1, 64, -1, -1, 1), _ignore_mon(false) TAVM_monitor::TAVM_monitor() : TAutomask("Monitor", 1, 64, -1, -1, 1), _ignore_mon(false)
{ {
//toolbar modernissima //toolbar modernissima
add_button_tool(DLG_NEXTREC, "Step F11", TOOL_NEXTREC).set_exit_key(K_F11); add_button_tool(DLG_NEXTREC, "Step", TOOL_NEXTREC).set_exit_key(K_F11);
add_button_tool(DLG_LASTREC, "Skip F10", TOOL_NEXTREC).set_exit_key(K_F10); add_button_tool(DLG_LASTREC, "Skip", TOOL_NEXTREC).set_exit_key(K_F10);
add_button_tool(DLG_ELABORA, "Run F5", TOOL_LASTREC).set_exit_key(K_F5); add_button_tool(DLG_ELABORA, "Run", TOOL_LASTREC).set_exit_key(K_F5);
add_button_tool(DLG_CANCEL, "NoMon F9", TOOL_CANCEL).set_exit_key(K_F9); add_button_tool(DLG_CANCEL, "No MON", TOOL_CANCEL).set_exit_key(K_F5);
add_button_tool(DLG_QUIT, "End", TOOL_QUIT).set_exit_key(K_QUIT); add_button_tool(DLG_QUIT, "Quit", TOOL_QUIT).set_exit_key(K_QUIT);
//campi vari //campi vari
//finestra con codice //finestra con codice
@ -948,7 +938,7 @@ void TAVM::execute(const TAVM_op& op)
break; break;
case avm_push: _stack.push(op.var()); break; case avm_push: _stack.push(op.var()); break;
case avm_repeat: _ip = op.var().as_int(); break; case avm_repeat: _ip = op.var().as_int(); break;
case avm_rdrop: _stack.push(_rstack.pop()); break; case avm_rpop: _stack.push(_rstack.pop()); break;
case avm_rpeek: _stack.push(_rstack.peek()); break; case avm_rpeek: _stack.push(_rstack.peek()); break;
case avm_rpush: _rstack.push(_stack.pop()); break; case avm_rpush: _rstack.push(_stack.pop()); break;
case avm_roll: _stack.roll(_stack.pop().as_int()); break; case avm_roll: _stack.roll(_stack.pop().as_int()); break;

View File

@ -78,10 +78,10 @@ public:
virtual long count( CONDITION_FUNCTION = NULL ); virtual long count( CONDITION_FUNCTION = NULL );
// @cmember Ritorna l'oggetto successivo a quello corrente // @cmember Ritorna l'oggetto successivo a quello corrente
TObject* operator++ () TObject* operator++ ()
{ return succ_item( ); }; { return succ_item( ); }
// @cmember Ritorna l'oggetto che precede quello corrente // @cmember Ritorna l'oggetto che precede quello corrente
TObject* operator-- () TObject* operator-- ()
{ return pred_item( ); }; { return pred_item( ); }
virtual ~TContainer() { } virtual ~TContainer() { }
}; };
@ -199,15 +199,11 @@ public:
}; };
inline TObject* TArray::objptr(int index) const inline TObject* TArray::objptr(int index) const
{ { return (index < _size && index >= 0) ? _data[index] : NULL; }
return (index < _size && index >= 0) ? _data[index] : NULL;
}
#ifndef DBG #ifndef DBG
inline TObject& TArray::operator[] (int index) const inline TObject& TArray::operator[] (int index) const
{ { return *objptr(index); }
return *objptr(index);
}
#endif #endif
#define FOR_EACH_ARRAY_ITEM(__arr, __r, __obj) \ #define FOR_EACH_ARRAY_ITEM(__arr, __r, __obj) \
@ -239,7 +235,7 @@ public:
long get_long(int index) const { return (long)objptr(index); } long get_long(int index) const { return (long)objptr(index); }
int get_int(int index) const { return (int)get_long(index); } int get_int(int index) const { return (int)get_long(index); }
int add_long(long value, int index = -1) { return add((TObject*)value, index); } int add_long(long value, int index = -1) { return add((TObject*)value, index); }
int insert_long(long value, int index = -1) { return TArray::insert((TObject*)value, index, TRUE); } int insert_long(long value, int index = -1) { return TArray::insert((TObject*)value, index, true); }
int find_long(long value) const; int find_long(long value) const;
TPointer_array() { } TPointer_array() { }

View File

@ -80,65 +80,41 @@
SP SP
; ;
: REP_ADD_IMPORTO ( dst_sezione_fld dst_valore_fld src_sezione src_valore -- ) : REP_ADD_IMPORTO ( f1 -- )
DUP \ dup src_valore #THIS @ \ leggo l'importo da sommare
EMPTY= IF \ se l'importo sorgente è nullo butta tutto e finisce qui EMPTY= IF \ se è nullo
DROP DROP \ butta tutto e finisce qui
DROP
DROP
DROP
ELSE ELSE
3 PICK >R \ prende dst_sezione_fld DUP \ duplica l'identificatore della destinazione
2 PICK >R \ prende dst_valore_fld >R \ memorizza l'identificare della destinazione nel return stack
>R \ store di src_valore @ \ valore della destinazione
>R \ store di src_sezione EMPTY= IF \ se è nullo
SWAP \ porta in cima allo stack la dst_sezione_fld #THIS GET_ID_NEXT @ \ recupera la sezione sorgente
DUP \ la duplica perchè la perde la riga dopo R@ GET_ID_NEXT ! \ imposta la sezione destinazione
@ \ prende il valore di dst_sezione_fld #THIS @ \ recupera il valore sorgente
R@ ! \ imposta il valore destinazione
EMPTY= IF \ se la dst_sezione_fld è vuota
R> \ recupera la src_sezione
SWAP \ gira i due termini
! \ assegna il contenuto della src_sezione al campo dst_sezione_fld
R> \ prende src_valore
SWAP \ gira i campi src_valore e dst_valore_fld
! \ assegna src_valore al campo dst_valore_fld
ELSE ELSE
@ #THIS @ \ leggo l'importo da sommare
R> \ legge src_sezione #THIS GET_ID_NEXT @ \ leggo la sezione sorgente
= IF R@ GET_ID_NEXT @ \ leggo la sezione destinazione
R> \ prende src_valore <> IF \ se sono diverse
ELSE -1 * \ inverte valore
R> \ prende src_valore
-1 * \ inverte il segno di src_valore
THEN THEN
SWAP \ gira i campi sullo stack src_valore dst_valore_fld R@ +! \ incrementa la destinazione
+! \ somma src_valore con segno rovesciato al campo dst_valore_fld
THEN THEN
\ normalizzazione della destinazione R@ @ \ recupera valore destinazione da normalizzare
MON
R@ \ recupera dst_valore_fld
@ \ legge il valore di dst_valore_fld
DUP \ lo duplica per possibile cambio di segno
0 < IF \ se il valore è negativo 0 < IF \ se il valore è negativo
-1 * \ gli cambia segno R@ @ -1 * \ gli cambia segno
R> \ recupera ancora dst_valore_fld R@ ! \ lo risalva positivo
! \ salva il valore positivo nel campo dst_valore_fld R@ GET_ID_NEXT @ \ recupera sezione di destinazione
R@ \ recupera dst_sezione_fld "A" = IF \ la inverte
@ \ legge il valore di dst_sezione_fld
"A" = IF \ lo inverte
"D" "D"
ELSE ELSE
"A" "A"
THEN THEN
R> \ recupera ancora dst_sezione_fld R@ GET_ID_NEXT ! \ salva nuova sezione
! \ salva il valore cambiato della sezione in dst_sezione_fld
ELSE
DROP \ se non deve invertire nulla svuota gli stack
R>
R>
THEN THEN
R> \ ripristina il return stack
THEN THEN
; ;
@ -274,7 +250,11 @@ THEN
#SYSTEM.DATE @ \ Leggo la data #SYSTEM.DATE @ \ Leggo la data
#THIS ! \ Setto il campo corrente con la data #THIS ! \ Setto il campo corrente con la data
; ;
: MESSAGE_DITTA ( s1 -- ) : MESSAGE_DITTA ( s1 -- )
GET_FIRM_DATA \ Campi della ditta corrente GET_FIRM_DATA \ Campi della ditta corrente
; ;
: MESSAGE_ADD_IMPORTO ( f1 -- )
REP_ADD_IMPORTO \ Incrementa un importo presumendo sia seguito dalla sua sezione
;

View File

@ -1119,6 +1119,24 @@ TObject* TReport_array_item::dup() const
// TReport_field // TReport_field
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
TReport_field* TReport_field::next() const
{
const TArray& sec = section();
for (int i = sec.last()-1; i >= 0; i--)
if (sec.objptr(i) == this)
return (TReport_field*)sec.objptr(i+1);
return NULL;
}
TReport_field* TReport_field::prev() const
{
const TArray& sec = section();
for (int i = sec.last(); i > 0; i--)
if (sec.objptr(i) == this)
return (TReport_field*)sec.objptr(i-1);
return NULL;
}
void TReport_field::set_pos(long x, long y) void TReport_field::set_pos(long x, long y)
{ {
_rct.x = x; _rct.x = x;
@ -1820,7 +1838,7 @@ bool TReport_field::load(const TXmlItem& fld)
activate(!fld.GetBoolAttr("deactivated")); activate(!fld.GetBoolAttr("deactivated"));
hide_zeroes(fld.GetBoolAttr("hide_zero")); hide_zeroes(fld.GetBoolAttr("hide_zero"));
set_border(fld.GetIntAttr("border")); set_border(fld.GetIntAttr("border"));
set_pattern((PAT_STYLE)fld.GetIntAttr("pattern", PAT_SOLID)); set_pattern((PAT_STYLE)fld.GetIntAttr("pattern", PAT_HOLLOW));
set_radius(fld.GetIntAttr("radius")); set_radius(fld.GetIntAttr("radius"));
set_shadow_offset(fld.GetIntAttr("shade_offset")); set_shadow_offset(fld.GetIntAttr("shade_offset"));
set_back_color(get_col_attr(fld, "bg_color", COLOR_WHITE)); set_back_color(get_col_attr(fld, "bg_color", COLOR_WHITE));
@ -2108,16 +2126,15 @@ int TReport::parse_field(const char* code, char& type, int& level, int& id) cons
if (strchr(code, '.') != NULL) if (strchr(code, '.') != NULL)
return 0; // Mi sono confuso con un campo su file, es: 34.CODART return 0; // Mi sono confuso con un campo su file, es: 34.CODART
id = atoi(code);
TReport_field* rf = curr_field(); TReport_field* rf = curr_field();
if (rf != NULL) if (rf != NULL)
{ {
type = rf->section().type(); type = rf->section().type();
level = rf->section().level(); level = rf->section().level();
}
if (code[0] == 'T') if (code[0] == 'T')
id = rf->id(); id = rf->id();
else }
id = atoi(code);
} }
else else
{ {
@ -2159,6 +2176,7 @@ TReport_field* TReport::field(const char* code)
else else
rf = curr_field(); rf = curr_field();
} }
return rf; return rf;
} }
@ -2614,8 +2632,10 @@ size_t TReport::get_usr_words(TString_array& words) const
{ {
const char* const name[] = const char* const name[] =
{ {
"***", "DISABLE", "ENABLE", "GET_POS", "***", "DISABLE", "ENABLE",
"GET_SIZE", "HIDE", "ISAM_READ", "RUN_FORM", "SET_BACK_COLOR", "SET_FORE_COLOR", "GET_ID", "GET_ID_NEXT", "GET_ID_PREV",
"GET_POS", "GET_SIZE", "HIDE", "ISAM_READ",
"RUN_FORM", "SET_BACK_COLOR", "SET_FORE_COLOR",
"SET_POS", "SET_SIZE", "SHOW", "TABLE_READ", "GET_FIRM_DATA", NULL "SET_POS", "SET_SIZE", "SHOW", "TABLE_READ", "GET_FIRM_DATA", NULL
}; };
size_t i; size_t i;
@ -3119,6 +3139,28 @@ void TReport::msg_firm(TVariant_stack& stack)
} }
} }
// Scrive in var il codice del campo, con o senza sezione nel prefisso
// a seconda che sia un fratello del campo corrente o no
HIDDEN bool fld2id(TReport_field* fld, TVariant& var)
{
var.set_null();
if (fld != NULL)
{
TReport_section& sec = fld->section();
TReport& rep = sec.report();
TReport_field* curr = rep.curr_field();
if (curr == NULL || &sec != &curr->section())
{
TString16 str;
str << sec.type() << sec.level() << '.' << fld->id();
var.set(str);
}
else
var.set(fld->id());
}
return var.is_null();
}
bool TReport::execute_usr_word(unsigned int opcode, TVariant_stack& stack) bool TReport::execute_usr_word(unsigned int opcode, TVariant_stack& stack)
{ {
switch (opcode) switch (opcode)
@ -3131,7 +3173,30 @@ bool TReport::execute_usr_word(unsigned int opcode, TVariant_stack& stack)
case 3: // ENABLE case 3: // ENABLE
do_message(stack.pop(), do_enable, (void*)1); do_message(stack.pop(), do_enable, (void*)1);
break; break;
case 4: // GET_POS case 4: // GET_ID
{
TVariant& var = stack.peek();
TReport_field* f = field(var.as_string());
fld2id(f, var);
}
break;
case 5: // GET_ID_NEXT
{
TVariant& var = stack.peek();
TReport_field* f = field(var.as_string());
if (f != NULL) f = f->next();
fld2id(f, var);
}
break;
case 6: // GET_ID_PREV
{
TVariant& var = stack.peek();
TReport_field* f = field(var.as_string());
if (f != NULL) f = f->prev();
fld2id(f, var);
}
break;
case 7: // GET_POS
{ {
real x, y; real x, y;
int level, id; int level, id;
@ -3153,7 +3218,7 @@ bool TReport::execute_usr_word(unsigned int opcode, TVariant_stack& stack)
stack.push(x); stack.push(y); stack.push(x); stack.push(y);
} }
break; break;
case 5: // GET_SIZE case 8: // GET_SIZE
{ {
real w, h; real w, h;
int level, id; int level, id;
@ -3180,34 +3245,34 @@ bool TReport::execute_usr_word(unsigned int opcode, TVariant_stack& stack)
stack.push(w); stack.push(h); stack.push(w); stack.push(h);
} }
break; break;
case 6: // HIDE case 9: // HIDE
do_message(stack.pop(), do_show, NULL); do_message(stack.pop(), do_show, NULL);
break; break;
case 7: // ISAM_READ case 10: // ISAM_READ
msg_isam_read(stack); msg_isam_read(stack);
break; break;
case 8: // RUN_FORM case 11: // RUN_FORM
{ {
const TString& msk = stack.pop().as_string(); const TString& msk = stack.pop().as_string();
const KEY key = run_form(msk); const KEY key = run_form(msk);
stack.push(key); stack.push(key);
} }
break; break;
case 9: // SET_BACK_COLOR case 12: // SET_BACK_COLOR
{ {
const TVariant& fld = stack.pop(); const TVariant& fld = stack.pop();
const COLOR rgb = stack.pop().as_color(); const COLOR rgb = stack.pop().as_color();
do_message(fld, do_set_back_color, (void*)rgb); do_message(fld, do_set_back_color, (void*)rgb);
} }
break; break;
case 10: // SET_FORE_COLOR case 13: // SET_FORE_COLOR
{ {
const TVariant& fld = stack.pop(); const TVariant& fld = stack.pop();
const COLOR rgb = stack.pop().as_color(); const COLOR rgb = stack.pop().as_color();
do_message(fld, do_set_fore_color, (void*)rgb); do_message(fld, do_set_fore_color, (void*)rgb);
} }
break; break;
case 11: // SET_POS case 14: // SET_POS
{ {
const TVariant& fld = stack.pop(); const TVariant& fld = stack.pop();
const real y = stack.pop().as_real() * CENTO; const real y = stack.pop().as_real() * CENTO;
@ -3216,7 +3281,7 @@ bool TReport::execute_usr_word(unsigned int opcode, TVariant_stack& stack)
do_message(fld, do_set_pos, (void*)&pt); do_message(fld, do_set_pos, (void*)&pt);
} }
break; break;
case 12: // SET_SIZE case 15: // SET_SIZE
{ {
const TVariant& fld = stack.pop(); const TVariant& fld = stack.pop();
const real h = stack.pop().as_real() * CENTO; const real h = stack.pop().as_real() * CENTO;
@ -3225,13 +3290,13 @@ bool TReport::execute_usr_word(unsigned int opcode, TVariant_stack& stack)
do_message(fld, do_set_size, (void*)&sz); do_message(fld, do_set_size, (void*)&sz);
} }
break; break;
case 13: // SHOW case 16: // SHOW
do_message(stack.pop(), do_show, (void*)1); do_message(stack.pop(), do_show, (void*)1);
break; break;
case 14: // TABLE_READ case 17: // TABLE_READ
msg_table_read(stack); msg_table_read(stack);
break; break;
case 15: // GET_FIRM_DATA case 18: // GET_FIRM_DATA
msg_firm(stack); msg_firm(stack);
break; break;
default: default:

View File

@ -493,6 +493,9 @@ public:
void save(TXmlItem& root) const; void save(TXmlItem& root) const;
bool load(const TXmlItem& root); bool load(const TXmlItem& root);
TReport_field* next() const;
TReport_field* prev() const;
TReport_field(TReport_section* sec); TReport_field(TReport_section* sec);
TReport_field(const TReport_field& rf); TReport_field(const TReport_field& rf);
virtual ~TReport_field(); virtual ~TReport_field();