Patch level : OMASA
Files correlati : cgp4.exe Ricompilazione Demo : [ ] Commento : sistemata tabella di conversione numeri negativi git-svn-id: svn://10.65.10.50/trunk@12165 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
99fbfa77a3
commit
2fb82efac7
116
cg/cgp4100.cpp
116
cg/cgp4100.cpp
@ -25,7 +25,7 @@
|
||||
#define MAX_CG_ROWS 98
|
||||
|
||||
// tabella per la conversione dei numeri negativi (schede perforate????)
|
||||
static unsigned char _tabella[10] = {0x7d,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0x50,0x51,0x52};
|
||||
static unsigned char _tabella[10] = {'p','q','r','s','t','u','v','w','x','y'};
|
||||
|
||||
// TAutomask
|
||||
|
||||
@ -56,10 +56,6 @@ protected:
|
||||
virtual void validate(TCursor& cur,TRecord_text &rec, TToken_string &val, TString& str);
|
||||
|
||||
public:
|
||||
void negativo(TString& importo);
|
||||
int strip_zero(TString& importo);
|
||||
bool my_isdigit(unsigned char ch);
|
||||
int look(unsigned char carattere);
|
||||
TOmasa_file(const TString& file_name);
|
||||
virtual ~TOmasa_file() { }
|
||||
};
|
||||
@ -77,64 +73,10 @@ void TOmasa_file::validate(TCursor& cur,TRecord_text &rec, TToken_string &s, TSt
|
||||
{
|
||||
valore.upper();
|
||||
}
|
||||
else if (code == "_IMPORTO")
|
||||
{
|
||||
negativo(valore);
|
||||
}
|
||||
else NFCHECK("Macro non definita: %s", (const char *)code);
|
||||
str = valore;
|
||||
}
|
||||
|
||||
int TOmasa_file::strip_zero(TString& importo)
|
||||
{
|
||||
TString16 app;
|
||||
|
||||
int size = importo.len();
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
if (importo[i] != '0') break;
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
app = importo.mid(importo[i] == '.' ? i - 1 : i);
|
||||
importo = app;
|
||||
}
|
||||
|
||||
return (i ? i - 1 : i);
|
||||
}
|
||||
|
||||
bool TOmasa_file::my_isdigit(unsigned char ch)
|
||||
{
|
||||
return (ch >= '0' && ch <= '9');
|
||||
}
|
||||
|
||||
int TOmasa_file::look(unsigned char carattere)
|
||||
{
|
||||
for (int i = 0; i < 10; i++)
|
||||
if (_tabella[i] == carattere)
|
||||
return i;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void TOmasa_file::negativo(TString& importo)
|
||||
{
|
||||
strip_zero(importo);
|
||||
int size = importo.len();
|
||||
if (!size) return;
|
||||
unsigned char last = importo[size - 1];
|
||||
if (!my_isdigit(last))
|
||||
{
|
||||
int new_last = look(last);
|
||||
TString16 dep; dep << new_last;
|
||||
if (new_last >= 0)
|
||||
{
|
||||
importo[size - 1] = dep[0];
|
||||
importo.insert("-");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TSkeleton_application
|
||||
|
||||
class TOmasa : public TSkeleton_application
|
||||
@ -156,6 +98,10 @@ public:
|
||||
virtual void ini2mask();
|
||||
virtual void mask2ini();
|
||||
bool transfer();
|
||||
void negativo(TString& importo);
|
||||
int strip_zero(TString& importo);
|
||||
bool my_isdigit(unsigned char ch);
|
||||
int look(unsigned char carattere);
|
||||
|
||||
TOmasa() {}
|
||||
};
|
||||
@ -187,6 +133,56 @@ bool TOmasa::destroy()
|
||||
return TApplication::destroy();
|
||||
}
|
||||
|
||||
int TOmasa::strip_zero(TString& importo)
|
||||
{
|
||||
TString16 app;
|
||||
|
||||
int size = importo.len();
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
if (importo[i] != '0') break;
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
app = importo.mid(importo[i] == '.' ? i - 1 : i);
|
||||
importo = app;
|
||||
}
|
||||
|
||||
return (i ? i - 1 : i);
|
||||
}
|
||||
|
||||
bool TOmasa::my_isdigit(unsigned char ch)
|
||||
{
|
||||
return (ch >= '0' && ch <= '9');
|
||||
}
|
||||
|
||||
int TOmasa::look(unsigned char carattere)
|
||||
{
|
||||
for (int i = 0; i < 10; i++)
|
||||
if (_tabella[i] == carattere)
|
||||
return i;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void TOmasa::negativo(TString& importo)
|
||||
{
|
||||
strip_zero(importo);
|
||||
int size = importo.len();
|
||||
if (!size) return;
|
||||
unsigned char last = importo[size - 1];
|
||||
if (!my_isdigit(last))
|
||||
{
|
||||
int new_last = look(last);
|
||||
TString16 dep; dep << new_last;
|
||||
if (new_last >= 0)
|
||||
{
|
||||
importo[size - 1] = dep[0];
|
||||
importo.insert("-");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TOmasa::mask2ini()
|
||||
{
|
||||
TSheet_field& sheet = (TSheet_field&)_msk->field(F_SHEET_CONTI);
|
||||
@ -294,6 +290,7 @@ bool TOmasa::transfer()
|
||||
pi.setstatus(_trasfile->read_file()->tellg());
|
||||
TString impstr = curr.get(F_VALOREVOCE);
|
||||
impstr.insert(".",11);
|
||||
negativo(impstr);
|
||||
const real importo(impstr);
|
||||
TString16 contodare = curr.get(F_CONTODARE);
|
||||
TString16 contoavere = curr.get(F_CONTOAVERE);
|
||||
@ -323,7 +320,6 @@ bool TOmasa::transfer()
|
||||
movpn->set_paragraph("IMPORTI");
|
||||
contodare.trim();
|
||||
impstr = movpn->get(contodare, "IMPORTI");
|
||||
// verificare se l'ultimo carattere e'una lettera = importo negativo
|
||||
real importomem(impstr);
|
||||
importomem+=importo;
|
||||
movpn->set(contodare, importomem.string());
|
||||
|
Loading…
x
Reference in New Issue
Block a user