Corretti alcune minchiatine di coversione long->int

git-svn-id: svn://10.65.10.50/trunk@304 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
guy 1994-10-03 09:57:55 +00:00
parent fb0ebca1cc
commit 832f08d056
3 changed files with 918 additions and 916 deletions

View File

@ -1,210 +1,212 @@
#include <stdlib.h> #include <stdlib.h>
#include <applicat.h> #include <applicat.h>
#include <xvtility.h> #include <xvtility.h>
#include <utility.h> #include <utility.h>
#include <prefix.h> #include <prefix.h>
#include <mask.h> #include <mask.h>
#include <isam.h> #include <isam.h>
#include <string.h> #include <string.h>
#include <sheet.h> #include <sheet.h>
#include <msksheet.h> #include <msksheet.h>
#include <progind.h> #include <progind.h>
#include <urldefid.h> #include <urldefid.h>
#include <validate.h> #include <validate.h>
#include "ba1.h" #include "ba1.h"
#include "ba1300.h" #include "ba1300.h"
#include "ba1300a.h" #include "ba1300a.h"
class BA1300_application:public TApplication class BA1300_application:public TApplication
{ {
TTestSheet * _testsheet; TTestSheet * _testsheet;
TTestProc * _test, TTestProc * _test,
* _debug; * _debug;
TMask * _mask; TMask * _mask;
long _firm; long _firm;
protected: protected:
virtual bool menu(MENU_TAG); virtual bool menu(MENU_TAG);
virtual bool create () ; virtual bool create () ;
virtual bool destroy(); virtual bool destroy();
virtual bool extended_firm() const { return TRUE; } virtual bool extended_firm() const { return TRUE; }
public: public:
BA1300_application() : _testsheet(NULL), _mask(NULL) {} BA1300_application() : _testsheet(NULL), _mask(NULL) {}
TTestSheet * get_sheet() {return _testsheet;} TTestSheet * get_sheet() {return _testsheet;}
TTestProc * get_test() {return _test;} TTestProc * get_test() {return _test;}
TMask * get_mask() {return _mask;} TMask * get_mask() {return _mask;}
TArray_sheet * field_sheet(TMask *); TArray_sheet * field_sheet(TMask *);
}; };
HIDDEN bool seq_handler(TMask_field& f, KEY key) HIDDEN bool seq_handler(TMask_field& f, KEY key)
{ {
if (key==K_ENTER) if (key==K_ENTER)
if (!fexist((const char*)f.get())) if (!fexist((const char*)f.get()))
{ {
warning_box("File inesistente"); warning_box("File inesistente");
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
} }
bool BA1300_application::create() // initvar e arrmask bool BA1300_application::create() // initvar e arrmask
{ {
_firm = get_firm(); _firm = get_firm();
if (argc() > 2) if (argc() > 2)
{ {
return FALSE; return FALSE;
} }
else else
{ {
_mask = new TMask ("ba1300a"); // Maschera principale _mask = new TMask ("ba1300a"); // Maschera principale
set_firm(); set_firm();
_testsheet = new TTestSheet("Selezione Files") ; _testsheet = new TTestSheet("Selezione Files") ;
get_sheet()->add_button(DLG_RESET,"~Reset",K_F6); get_sheet()->add_button(DLG_RESET,"~Reset",K_F6);
} }
return TRUE ; return TRUE ;
} }
bool BA1300_application::destroy() // releasev e arrmask bool BA1300_application::destroy() // releasev e arrmask
{ {
if (_firm) set_firm(_firm); if (_firm) set_firm(_firm);
if (_testsheet != NULL) delete _testsheet; if (_testsheet != NULL) delete _testsheet;
if (_mask != NULL) delete _mask; if (_mask != NULL) delete _mask;
return TRUE ; return TRUE ;
} }
TArray_sheet * BA1300_application::field_sheet(TMask * m) TArray_sheet * BA1300_application::field_sheet(TMask * m)
{ {
TEdit_field& f=(TEdit_field&) m->field(F_FILE); TEdit_field& f=(TEdit_field&) m->field(F_FILE);
TArray_sheet * s=(TArray_sheet*) f.sheet()->sheet(); TArray_sheet * s=(TArray_sheet*) f.sheet()->sheet();
return s; return s;
} }
bool BA1300_application::menu(MENU_TAG m) bool BA1300_application::menu(MENU_TAG m)
{ {
KEY tasto,tastoS; KEY tasto,tastoS;
long numtest; long numtest;
TMask *msk; TMask *msk;
TDir *cdir; TDir *cdir;
disable_menu_item(M_FILE_NEW); disable_menu_item(M_FILE_NEW);
switch (m) switch (m)
{ {
case BAR_ITEM(2): case BAR_ITEM(2):
msk = new TMask("ba1300b"); {
cdir = new TDir; msk = new TMask("ba1300b");
cdir->get(LF_DIR,_nolock,_nordir,_sysdirop); cdir = new TDir;
const int nitems=cdir->eod(); cdir->get(LF_DIR,_nolock,_nordir,_sysdirop);
for (int i=0; i<nitems;i++) // fill sheet const int nitems=(int)cdir->eod();
{ for (int i=0; i<nitems;i++) // fill sheet
TToken_string riga(128); {
riga.cut(0); TToken_string riga(128);
cdir->get(i+1,_nolock,_nordir,_sysdirop); riga.cut(0);
riga=format("%3d",i+1); cdir->get(i+1,_nolock,_nordir,_sysdirop);
riga.add(cdir->name()); riga=format("%3d",i+1);
riga.add(format("%ld",cdir->eod())); riga.add(cdir->name());
riga.add(format("%ld",cdir->eox())); riga.add(format("%ld",cdir->eod()));
riga.add(format("%u",cdir->len())); riga.add(format("%ld",cdir->eox()));
riga.add(cdir->des()); riga.add(format("%u",cdir->len()));
field_sheet(msk)->add(riga); riga.add(cdir->des());
} field_sheet(msk)->add(riga);
msk->set_handler(F_SEQUENZA,seq_handler); }
if (msk->run()==K_ENTER) msk->set_handler(F_SEQUENZA,seq_handler);
{ if (msk->run()==K_ENTER)
_debug = new TTestProc; {
_debug->set_file(msk->get_long(F_FILE)); _debug = new TTestProc;
_debug->load_random(msk->get(F_SEQUENZA)); _debug->set_file(msk->get_int(F_FILE));
if (!_debug->stopped()) _debug->load_random(msk->get(F_SEQUENZA));
_debug->do_debug(); if (!_debug->stopped())
else _debug->do_debug();
warning_box("File di sequenza non valido"); else
delete _debug; warning_box("File di sequenza non valido");
} delete _debug;
delete msk; }
delete cdir; delete msk;
break; delete cdir;
case BAR_ITEM(1): }
do { break;
switch(tasto=get_mask()->run()) case BAR_ITEM(1):
{ do {
case K_ENTER: switch(tasto=get_mask()->run())
if (get_sheet()->checked()>0 && (get_mask()->get_long(F_ITERAZIONI)>0 || get_mask()->get_bool(F_CONTINUO))) {
{ case K_ENTER:
_test = new TTestProc; if (get_sheet()->checked()>0 && (get_mask()->get_long(F_ITERAZIONI)>0 || get_mask()->get_bool(F_CONTINUO)))
get_test()->set_sheet(get_sheet()); {
get_test()->set_rmc(); _test = new TTestProc;
get_test()->get_win()->set_color(COLOR_BLACK,COLOR_WHITE); get_test()->set_sheet(get_sheet());
get_test()->get_win()->clear(COLOR_WHITE); get_test()->set_rmc();
get_test()->get_win()->set_caption("Verifica di stabilita'"); get_test()->get_win()->set_color(COLOR_BLACK,COLOR_WHITE);
get_test()->get_win()->WriteW(10,5,"Test N. :"); get_test()->get_win()->clear(COLOR_WHITE);
get_test()->get_win()->WriteW(10,7,"Nome File :"); get_test()->get_win()->set_caption("Verifica di stabilita'");
get_test()->get_win()->WriteW(10,9,"Record cancellati :"); get_test()->get_win()->WriteW(10,5,"Test N. :");
get_test()->get_win()->WriteW(10,10,"Operazione in corso :"); get_test()->get_win()->WriteW(10,7,"Nome File :");
get_test()->get_win()->WriteW(10,12,"Tempo trascorso :"); get_test()->get_win()->WriteW(10,9,"Record cancellati :");
get_test()->get_win()->WriteW(10,13,"Tempo stimato :"); get_test()->get_win()->WriteW(10,10,"Operazione in corso :");
get_test()->get_win()->WriteW(10,15,"Ultimo Errore :"); get_test()->get_win()->WriteW(10,12,"Tempo trascorso :");
numtest=0; get_test()->get_win()->WriteW(10,13,"Tempo stimato :");
while (((++numtest)<=get_mask()->get_long(F_ITERAZIONI) || get_mask()->get_bool(F_CONTINUO)) && (!get_test()->stopped())) get_test()->get_win()->WriteW(10,15,"Ultimo Errore :");
{ numtest=0;
if (get_mask()->get_bool(F_CONTINUO)) while (((++numtest)<=get_mask()->get_long(F_ITERAZIONI) || get_mask()->get_bool(F_CONTINUO)) && (!get_test()->stopped()))
get_test()->get_win()->WriteW(33,5,(const char*)TString(20).format("%4ld (CONTINUO)",numtest)); {
else if (get_mask()->get_bool(F_CONTINUO))
get_test()->get_win()->WriteW(33,5,(const char*)TString(20).format("%4ld/%-4ld",numtest,_mask->get_long(F_ITERAZIONI))); get_test()->get_win()->WriteW(33,5,format("%4ld (CONTINUO)",numtest));
get_test()->set_numt(numtest); else
get_test()->do_test_1(); get_test()->get_win()->WriteW(33,5,format("%4ld/%-4ld",numtest,_mask->get_long(F_ITERAZIONI)));
} get_test()->set_numt(numtest);
if (get_test()->rm_copy()) get_test()->do_test_1();
{ }
get_test()->get_win()->WriteW(33,10,"CANCELLAZIONE COPIE "); if (get_test()->rm_copy())
for (long i=0;i<get_sheet()->items();i++) {
if (get_sheet()->checked(i)) get_test()->get_win()->WriteW(33,10,"CANCELLAZIONE COPIE ");
get_test()->remove_copy(i+1); for (int i=0;i<get_sheet()->items();i++)
} if (get_sheet()->checked(i))
delete _test; get_test()->remove_copy(i+1);
} }
else delete _test;
warning_box("Nessun file selezionato"); }
break; else
case K_F4: warning_box("Nessun file selezionato");
get_sheet()->sr_status(); break;
while ((tastoS=get_sheet()->run()) == K_F6) case K_F4:
for (int i=0; i<get_sheet()->items();i++) get_sheet()->sr_status();
get_sheet()->uncheck(i); while ((tastoS=get_sheet()->run()) == K_F6)
if (tastoS == K_ESC) for (int i=0; i<get_sheet()->items();i++)
get_sheet()->sr_status(FALSE); get_sheet()->uncheck(i);
else if (tastoS == K_ESC)
{ // Cannot select first two files. get_sheet()->sr_status(FALSE);
get_sheet()->uncheck(0); else
get_sheet()->uncheck(1); { // Cannot select first two files.
} get_sheet()->uncheck(0);
break; get_sheet()->uncheck(1);
case K_F5: }
if (fexist((const char*)TString(20).format("test%creport.txt",Separator))) break;
{ case K_F5:
TTestReport rep_win("Report"); if (fexist((const char*)TString(20).format("test%creport.txt",Separator)))
rep_win.load_report(); {
rep_win.run(); TTestReport rep_win("Report");
} else rep_win.load_report();
warning_box("Report non disponibile"); rep_win.run();
break; } else
default: warning_box("Report non disponibile");
break; break;
} default:
} while (tasto != K_ESC); break;
break; }
} } while (tasto != K_ESC);
enable_menu_item(M_FILE_NEW); break;
return xvt_test_menu_tag(BAR_ITEM(2)); }
} enable_menu_item(M_FILE_NEW);
return xvt_test_menu_tag(BAR_ITEM(2));
int ba1300(int argc, char** argv) }
{
BA1300_application a; int ba1300(int argc, char** argv)
a.run(argc,argv,"Test dell'ISAM"); {
return 0; BA1300_application a;
} a.run(argc,argv,"Test dell'ISAM");
return 0;
}

View File

@ -1,103 +1,103 @@
#ifndef __BA1300_H #ifndef __BA1300_H
#define __BA1300_H #define __BA1300_H
#include "ba1100.h" #include "ba1100.h"
#if XVT_OS == XVT_OS_WIN #if XVT_OS == XVT_OS_WIN
#define Separator '\\' #define Separator '\\'
#else #else
#define Separator '/' #define Separator '/'
#endif #endif
//////////////////////////////////////// ////////////////////////////////////////
// Here defining classes // // Here defining classes //
//////////////////////////////////////// ////////////////////////////////////////
class TTestSheet : public TDir_sheet class TTestSheet : public TDir_sheet
{ {
TBit_array _oldstatus; // Previous status of selected files TBit_array _oldstatus; // Previous status of selected files
protected: protected:
void page_build(long first, byte rows); void page_build(long first, byte rows);
public: public:
TTestSheet(const char* titolo, const char* colonne="@1|N.@5|Nome@20|EOD@7|EOX@7|Lung. |Descrizione@43|Flags@7", byte bottoni=0x0); TTestSheet(const char* titolo, const char* colonne="@1|N.@5|Nome@20|EOD@7|EOX@7|Lung. |Descrizione@43|Flags@7", byte bottoni=0x0);
~TTestSheet() ; ~TTestSheet() ;
void sr_status(bool save=TRUE); void sr_status(bool save=TRUE);
}; };
class TTestFile : public TBaseisamfile class TTestFile : public TBaseisamfile
{ {
public: public:
TTestFile(int ln,bool lt=TRUE) : TBaseisamfile(ln,lt) {} TTestFile(int ln,bool lt=TRUE) : TBaseisamfile(ln,lt) {}
virtual ~TTestFile() {} virtual ~TTestFile() {}
int close() {return _close();} int close() {return _close();}
int open(unsigned int mode = _manulock) {return _open(mode);} int open(unsigned int mode = _manulock) {return _open(mode);}
const char * file_name() const {return filename();} const char * file_name() const {return filename();}
}; };
class TTestWin : public TIndwin class TTestWin : public TIndwin
{ {
protected: protected:
virtual void update() {update_text();} virtual void update() {update_text();}
virtual void handler(WINDOW w, EVENT *e); virtual void handler(WINDOW w, EVENT *e);
void update_text() {set_mode(M_COPY); check_stop();} void update_text() {set_mode(M_COPY); check_stop();}
public: public:
void WriteW(short x, short y, const char* line) {stringat(x,y,line);update_text();do_events();} void WriteW(short x, short y, const char* line) {stringat(x,y,line);update_text();do_events();}
TTestWin(); TTestWin();
~TTestWin() {}; ~TTestWin() {};
}; };
class TTestProc class TTestProc
{ {
TTestSheet * _sheet; // Sheet with files selected TTestSheet * _sheet; // Sheet with files selected
TTestFile * _workf; // working file TTestFile * _workf; // working file
TTestWin * _win; // Output window TTestWin * _win; // Output window
long * _randseq; // Random sequence long * _randseq; // Random sequence
long _ntest; // number of test in progress long _ntest; // number of test in progress
int _nfile; // number of file being tested int _nfile; // number of file being tested
long _kriminal; // number of record incriminated (Debug) long _kriminal; // number of record incriminated (Debug)
int _nkeys; // # of keys defined for current file int _nkeys; // # of keys defined for current file
bool _block; // is test blocked ? bool _block; // is test blocked ?
bool _rmc; // Remove copies at the end of test ? bool _rmc; // Remove copies at the end of test ?
protected: protected:
void do_random(long eod); void do_random(long eod);
void filecopy(bool save=TRUE); void filecopy(bool save=TRUE);
void DumpReport(int err, long i, long x, int key); void DumpReport(int err, long i, long x, int key);
long sumop(const long n) {return ((n+1)*(n/2)+(n%2)*((n+1)/2));} long sumop(const long n) {return ((n+1)*(n/2)+(n%2)*((n+1)/2));}
int ctrl_keys(); int ctrl_keys();
bool show_mess(int, int, long, long, int); bool show_mess(int, int, long, long, int);
const char * fmttime(const long); const char * fmttime(const long);
public: public:
TTestProc(); TTestProc();
~TTestProc(); ~TTestProc();
const char* get_base(); const char* get_base();
void do_test_1(); void do_test_1();
void do_test_2(); void do_test_2();
void do_debug(); void do_debug();
void remove_copy(long n); void remove_copy(int n);
void load_random(const TString& st); void load_random(const TString& st);
bool stopped() {return _block;} bool stopped() {return _block;}
bool rm_copy() {return _rmc;} bool rm_copy() {return _rmc;}
void set_rmc(bool a=FALSE) {_rmc = a;} void set_rmc(bool a=FALSE) {_rmc = a;}
long num_test() {return _ntest;} long num_test() {return _ntest;}
void set_numt(const long num) { _ntest = num;} void set_numt(const long num) { _ntest = num;}
long num_file() {return _nfile;} int num_file() {return _nfile;}
void set_file(long n) {_nfile=n;} void set_file(int n) {_nfile=n;}
long number(const long n) {return _randseq[n];} long number(const long n) {return _randseq[n];}
void set_sheet (TTestSheet * sh) {_sheet=sh;} void set_sheet (TTestSheet * sh) {_sheet=sh;}
TTestSheet * get_isheet() {return _sheet;} TTestSheet * get_isheet() {return _sheet;}
TTestWin * get_win() {return _win;} TTestWin * get_win() {return _win;}
}; };
class TTestReport : public TScroll_window class TTestReport : public TScroll_window
{ {
TArray _report; TArray _report;
protected: protected:
virtual void update(); virtual void update();
virtual bool on_key(KEY); virtual bool on_key(KEY);
public: public:
TTestReport(const char* title); TTestReport(const char* title);
~TTestReport() {}; ~TTestReport() {};
void load_report(); void load_report();
TString& get_row(int n) {return (TString&)_report[n];} TString& get_row(int n) {return (TString&)_report[n];}
}; };
#endif #endif

File diff suppressed because it is too large Load Diff