isam.cpp Migliorate conversioni dei TRecfield

printapp.cpp  Corretta formattazione dei long double
printer.cpp   Migliorato riconoscimento del fax
progind.cpp   Aggiorna la barro solo se cambia la percentuale
strings.cpp   Aggiunta funzione get_buffer


git-svn-id: svn://10.65.10.50/trunk@3952 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1996-12-02 11:01:06 +00:00
parent b6e4ac9fbe
commit 972e56a4bd
7 changed files with 77 additions and 35 deletions

View File

@ -3228,14 +3228,27 @@ void TRecfield::setptr(TRecnotype r)
TRecfield::operator int() const
{
__getfieldbuff( _len, _type, _p, _isam_string);
if (_type == _intfld || _type == _intzerofld || _type == _longfld || _type == _longzerofld)
{
strncpy(_isam_string, _p, _len);
_isam_string[_len] = '\0';
}
else
__getfieldbuff( _len, _type, _p, _isam_string);
return atoi(_isam_string);
}
TRecfield::operator long() const
{
__getfieldbuff( _len, _type, _p, _isam_string);
if (_type == _longfld || _type == _longzerofld || _type == _intfld || _type == _intzerofld)
{
strncpy(_isam_string, _p, _len);
_isam_string[_len] = '\0';
}
else
__getfieldbuff( _len, _type, _p, _isam_string);
return atol(_isam_string);
}
@ -3245,7 +3258,13 @@ TRecfield::operator long() const
TRecfield::operator const real() const
{
__getfieldbuff( _len, _type, _p, _isam_string);
if (_type == _realfld)
{
strncpy(_isam_string, _p, _len);
_isam_string[_len] = '\0';
}
else
__getfieldbuff( _len, _type, _p, _isam_string);
real r(_isam_string);
return r;
}
@ -3254,10 +3273,15 @@ TRecfield::operator const real() const
TRecfield::operator TDate() const
{
{
if (_type == _datefld)
{
strncpy(_isam_string, _p, 8);
_isam_string[8] = '\0';
return TDate(atol(_isam_string));
}
__getfieldbuff(_len, _type, _p, _isam_string);
TDate d(_isam_string);
return d;
return TDate(_isam_string);
}

View File

@ -848,7 +848,7 @@ void TPrint_application::set_row (
}
else
{
TString t;
TString80 formato;
switch (ch)
{
case '#':
@ -867,16 +867,16 @@ void TPrint_application::set_row (
else
{
// read format
t << ccc;
formato << ccc;
bool islong = FALSE;
while (strchr (printf_types, ch) == NULL)
{
t << ch;
formato << ch;
if (ch == 'l')
islong = TRUE;
ch = *fmt++;
if (ch == '\0')
fatal_box ("sorry, zer's samzing vruong uitz ioar format.");
NFCHECK("sorry, zer's samzing vruong uitz ioar format.");
}
if (isupper (ch))
{
@ -884,18 +884,18 @@ void TPrint_application::set_row (
fill = ' ';
}
if (ch == 't' || ch == 'a')
t << 's';
formato << 's';
else if (ch == 'r')
#ifdef __LONGDOUBLE__
t << "Lf";
formato << "Lf";
#else
t << 't';
formato << 't';
#endif
else
t << ch;
formato << ch;
if (ccc == '%')
{
TString q (60);
TString256 q;
switch (ch)
{
case 'd':
@ -904,30 +904,30 @@ void TPrint_application::set_row (
case 'o':
case 'x':
case 'X':
q.format (t, islong ? va_arg (params, long) : va_arg (params, int));
q.format (formato, islong ? va_arg (params, long) : va_arg (params, int));
break;
case 'f':
case 'e':
case 'E':
case 'G':
q.format (t, islong ? va_arg (params, double) : va_arg (params, float));
q.format (formato, islong ? va_arg (params, double) : va_arg (params, float));
break;
case 'c':
q.format (t, va_arg (params, char));
q.format (formato, va_arg (params, char));
break;
case 's':
q.format (t, va_arg (params, char *));
q.format (formato, va_arg (params, char *));
break;
case 't': // TString
q.format(t,(const char*)(TString)*((va_arg (params, TString*))));
q.format(formato,(const char*)(TString)*((va_arg (params, TString*))));
break;
case 'a': // TParagraph_string
q.format(t,(const char*)(TParagraph_string)*((va_arg (params, TParagraph_string*))));
q.format(formato,(const char*)(TParagraph_string)*((va_arg (params, TParagraph_string*))));
break;
case 'r': // Real
{
const real& rrr = * va_arg (params, real *);
if (t.len () == 2 && *_picture)
if (_picture[0] && (formato[2] == '\0' || formato == "%Lf"))
{
// no format specifications
// use default picture
@ -936,9 +936,9 @@ void TPrint_application::set_row (
else
{
#ifdef __LONGDOUBLE__
sprintf (__tmp_string, t, (long double)rrr);
sprintf (__tmp_string, formato, (long double)rrr);
#else
char *fff = (char*)(const char *)t;
char *fff = (char*)(const char *)formato;
dsprintf (__tmp_string, fff, rrr.ptr());
#endif
q = __tmp_string;
@ -956,7 +956,7 @@ void TPrint_application::set_row (
_rows.add (new _PrintfTok (_currow, q));
}
else
_rows.add (new _PrintfRef (_currow, t, ch, va_arg (params, void *)));
_rows.add (new _PrintfRef (_currow, formato, ch, va_arg (params, void *)));
}
}
break;

View File

@ -1115,7 +1115,7 @@ TPrinter::TPrinter()
bool TPrinter::isfax() const
{
bool fax = _printertype == winprinter || _printertype == screenvis;
bool fax = _printertype == winprinter /* || _printertype == screenvis */;
if (fax)
{
const char* name = (const char*)((TPrinter*)this)->get_printrcd() + 4;

View File

@ -158,6 +158,18 @@ TProgind::TProgind(long max, const char* txt, bool cancel, bool bar, int div)
: TIndwin(max, txt, cancel, bar, div)
{}
void TProgind::setstatus(long l)
{
const long old_perc = _status * 100L / _max;
_status = l > _max ? _max : l;
const long new_perc = _status * 100L / _max;
if (new_perc > old_perc)
{
update_bar();
do_events();
}
}
// TTimerind ------------------------------------------------------------
long TTimerind::_timer_id = 0L;

View File

@ -103,8 +103,7 @@ public:
void setmax(long m)
{ _max = m; }
// @cmember Setta lo stato della barra d'attesa
void setstatus(long l)
{ _status = l; update_bar(); do_events(); }
void setstatus(long l);
// @cmember Aggiorna la barra d'attesa aggiungendo l'incremento fatto dell'applicazione
void addstatus(long l)
{ setstatus(_status+l); }

View File

@ -693,6 +693,14 @@ TString& TString::format(
return *this;
}
// Certified 99%
char* TString::get_buffer(int min_size)
{
if (min_size > size())
resize(min_size, TRUE);
return _str;
}
// Certified 100%
TString& TString::upper()
{

View File

@ -164,16 +164,15 @@ public:
// @cmember Formatta una stringa usando il formato dato da pic
TString& picture(const char* pic, const char* s);
#ifndef __WATCOMC__
virtual
#endif
// @cmember Manda un output formattato alla stringa oggetto
TString& format(const char* fmt, ...);
// @cmember Manda un output formattato alla stringa oggetto
virtual TString& format(const char* fmt, ...);
// @cmember Tronca la stringa alla posizione n-esima.
TString& cut(int n);
// @cmember Ritorna il buffer interno della stringa (usare con attenzione!)
char* get_buffer(int min_size = -1);
// @cmember Converte la stringa in maiuscolo
TString& upper();