Metodo flength per gestire la scrittura su file di campi
con lunghezza diversa a quella del tracciato isam git-svn-id: svn://10.65.10.50/trunk@5675 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
d9594515f9
commit
cb93e09b80
@ -33,6 +33,14 @@ void TTracciato_campo::copy(const TTracciato_campo& tc)
|
||||
set_message(tc._message);
|
||||
}
|
||||
|
||||
// determina la lunghezza del campo da scrivere su file isam
|
||||
const int TFile_text::flength(const TTracciato_campo &tc , const TRectype & record ) const
|
||||
{
|
||||
if (tc.ftype().empty())
|
||||
return tc.field().len(record); // il default è la lunghezza del campo isam
|
||||
else
|
||||
return ((TTracciato_campo &)_tipi[tc.ftype()]).length(); // altrimenti è quella definita nel FTYPE
|
||||
}
|
||||
const int TFile_text::fdecimal(const TTracciato_campo &tc ) const
|
||||
{
|
||||
if (tc.ftype().empty())
|
||||
@ -638,7 +646,8 @@ int TFile_text::_autosave(TRelation& rel, const TRecord_text& rec, TTracciato_re
|
||||
{
|
||||
real numero(valore);
|
||||
valore = numero.string(fpicture(tc));//formatta il numero secondo le specifiche del tracciato
|
||||
int length = rel_rec.length(field.name());
|
||||
|
||||
int length = flength(tc,rel_rec);
|
||||
if (falign(tc) == 'R')
|
||||
valore.right_just(length, ffiller(tc));
|
||||
else
|
||||
@ -737,7 +746,9 @@ void TFile_text::format_date(const TDate& data, const TString& form, TString& da
|
||||
while (i <= form.len());
|
||||
}
|
||||
|
||||
//Formatta la stringa in base al tracciato
|
||||
// Formatta la stringa in base alle definizioni del tracciato
|
||||
// La stringa ritornata rappresenta il valore del campo nel filetext e i parametri di fomattazione
|
||||
// sono quelli associati al campo nel filetext
|
||||
TString& TFile_text::format_textfield(const TTracciato_campo& tc, TString& campo)
|
||||
{
|
||||
//int pos = tc.position();
|
||||
@ -766,12 +777,15 @@ TString& TFile_text::format_textfield(const TTracciato_campo& tc, TString& campo
|
||||
return campo;
|
||||
}
|
||||
|
||||
//Formatta la stringa in base al field del file isam
|
||||
// Formatta la stringa passata in base al field del file isam
|
||||
// La stringa ritornata rappresenta il valore del campo nel file isam e i parametri di fomattazione
|
||||
// sono quelli associati al campo nel file isam (metodi fpicture, falign ecc.)
|
||||
TString& TFile_text::format_field(const TTracciato_campo& tc, short lfile, TString& campo)
|
||||
{
|
||||
const TRectype record(tc.field().file() ? tc.field().file() : lfile);
|
||||
|
||||
int length = tc.field().len(record);
|
||||
int length = flength(tc,record);
|
||||
|
||||
if (!fpicture(tc).blank())
|
||||
{ TString tmp;
|
||||
tmp.picture(fpicture(tc), campo);
|
||||
|
@ -149,6 +149,7 @@ class TFile_text : public TObject
|
||||
int _typefield;//posizione ove trovare la chiave nel record a lunghezza variabile
|
||||
|
||||
protected:
|
||||
const int flength(const TTracciato_campo &tc, const TRectype & r ) const;
|
||||
const int fdecimal(const TTracciato_campo &tc ) const;
|
||||
const char falign(const TTracciato_campo &tc ) const;
|
||||
const char ffiller(const TTracciato_campo &tc ) const ;
|
||||
|
Loading…
x
Reference in New Issue
Block a user