From 03dd119937819adfc0c0137bd668b530243f65b8 Mon Sep 17 00:00:00 2001 From: guy Date: Thu, 5 Mar 1998 14:01:14 +0000 Subject: [PATCH] ba*.cpp Corretto uso dei bool per 32 bit ba883.cpp Migliorati test di velocita' batbban.uml Abbassata toolbar enorme git-svn-id: svn://10.65.10.50/trunk@6305 c028cbd2-c16b-5b4b-a496-9718f37d4682 --- ba/ba0.cpp | 6 +- ba/ba1100.cpp | 4 +- ba/ba1102.cpp | 2 +- ba/ba1600.cpp | 6 +- ba/ba1700.cpp | 7 +- ba/ba1800.cpp | 175 ++++--------------------------------------------- ba/ba883.cpp | 28 ++++---- ba/batbban.uml | 3 +- 8 files changed, 41 insertions(+), 190 deletions(-) diff --git a/ba/ba0.cpp b/ba/ba0.cpp index 90adbf83d..9968a4b8a 100755 --- a/ba/ba0.cpp +++ b/ba/ba0.cpp @@ -546,13 +546,17 @@ bool TMenuitem::enabled() const const int endname = _action.find(' '); TFilename name(endname > 0 ? _action.left(endname) : _action); const char* ext[] = { "exe", "pif", "com", "bat", NULL }; + yes = FALSE; for (int e = 0; ext[e]; e++) { name.ext(ext[e]); if (name.exist()) + { + yes = TRUE; break; + } + } - yes = ext[e] != NULL; if (!yes) ((TMenuitem*)this)->_enabled = FALSE; } diff --git a/ba/ba1100.cpp b/ba/ba1100.cpp index 2ff57ba41..9f49951d3 100755 --- a/ba/ba1100.cpp +++ b/ba/ba1100.cpp @@ -313,7 +313,7 @@ bool TManutenzione_app::create() // initvar e arrmask if (sw == "-D") { const int c = argc(); - bool des_too = 1; // Anche le descrizioni + bool des_too = TRUE; // Anche le descrizioni long modules = -1; // Tutti i moduli if (c < 4) { @@ -327,7 +327,7 @@ bool TManutenzione_app::create() // initvar e arrmask return FALSE; } if (c == 5) - des_too = (bool)atoi(argv(4)); + des_too = atoi(argv(4)) ? TRUE : FALSE; if (c == 6) modules = atol(argv(5)); prefix().set(""); diff --git a/ba/ba1102.cpp b/ba/ba1102.cpp index 4cc9adb7c..a4eb3fae4 100755 --- a/ba/ba1102.cpp +++ b/ba/ba1102.cpp @@ -136,7 +136,7 @@ bool TEdit_file::_browse(TCursor& cursor, const TFilename& name) } sheet.force_update(); } - return K_ESC; + return ch != K_ESC; } bool TEdit_file::browse(int logicnum, const TFilename& name, const TString& tab) diff --git a/ba/ba1600.cpp b/ba/ba1600.cpp index 18ca4d783..e48d6383c 100755 --- a/ba/ba1600.cpp +++ b/ba/ba1600.cpp @@ -1139,7 +1139,7 @@ bool TFascicolator_mask::set_version_info(const TFilename& filename, outfile.seekp(position); outfile.write(str, str.len()); } - ok = outfile.good(); + ok = outfile.good() != 0; if (!ok) error_box("Error writing signature in %s error n. %d", (const char *) filename, errno); } @@ -1184,7 +1184,7 @@ bool TFascicolator_mask::zip_module(const TString& main_module, bool agg, int pa TProgind pi(arr.items(), msg, TRUE, TRUE); TFilename cmd; struct _stat info; - unsigned long lasttime=0; + time_t lasttime=0; FOR_EACH_ARRAY_ROW_BACK(arr, i, row) { @@ -1205,7 +1205,7 @@ bool TFascicolator_mask::zip_module(const TString& main_module, bool agg, int pa submod.cut(2); set_version_info(cmd, ini, submod); } - _stat((const char *)cmd,&info); + _stat(cmd,&info); lasttime = max(lasttime,info.st_mtime); } else diff --git a/ba/ba1700.cpp b/ba/ba1700.cpp index 84caa5b7c..4326a54ae 100755 --- a/ba/ba1700.cpp +++ b/ba/ba1700.cpp @@ -804,16 +804,15 @@ bool TInstaller_mask::on_key(KEY key) else if (key == K_F8) { - for (long i = items()-1; i >=0; i--) + for (long i = items()-1; i >= 0; i--) { TToken_string r = row(i); const TString16 newver = r.get(C_RELEASE); const int newpatch = r.get_int(C_PATCH); const TString16 curver = r.get(C_CURRRELEASE); const int curpatch = r.get_int(C_CURRPATCH); - check(i, compare_version(newver, newpatch, curver, curpatch > 0)); - } - + check(i, compare_version(newver, newpatch, curver, curpatch) > 0); + } } else ok = TArray_sheet::on_key(key); diff --git a/ba/ba1800.cpp b/ba/ba1800.cpp index e0e70e846..044419d03 100755 --- a/ba/ba1800.cpp +++ b/ba/ba1800.cpp @@ -1,9 +1,9 @@ #include #include +#include #include #include -#include #include #include #include @@ -87,156 +87,7 @@ HIDDEN int choose_isamfile(int selected) } /////////////////////////////////////////////////////////// -// THandled_mask -/////////////////////////////////////////////////////////// - -enum TField_event { fe_null, fe_init, fe_modify, fe_button, fe_close, - se_enter, se_query_modify, se_notify_modify, - se_query_add, se_notify_add, - se_query_del, se_notify_del }; - -class THandled_mask : public TMask -{ -private: - static bool universal_handler(TMask_field& f, KEY k); - static bool universal_notifier(TSheet_field& f, int row, KEY k); - -protected: - void set_handlers(); - -public: - virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly) pure; - bool error_box(const char* fmt, ...); // No more f.error_box - - THandled_mask() { } - THandled_mask(const char* name, int num = 0); - virtual ~THandled_mask() { } -}; - -bool THandled_mask::error_box(const char* fmt, ...) -{ - TString message(1024); - char* msg = message.get_buffer(); - va_list argptr; - va_start(argptr, fmt); - int len = vsprintf(msg, fmt, argptr); - CHECKD(len <= message.size(), "Error message too long: ", len); - va_end(argptr); - - if (is_sheetmask() && !is_running()) - { - xvt_statbar_set(msg); - beep(); - } - else - { - post_error_message(msg, 3); - } - - return FALSE; -} - -bool THandled_mask::universal_handler(TMask_field& f, KEY key) -{ - THandled_mask& wm = (THandled_mask&)f.mask(); - TOperable_field& of = (TOperable_field&)f; - TField_event fe = fe_null; - long jolly = key; - switch (key) - { - case K_TAB: - if (wm.is_running() || wm.get_sheet() != NULL) - { - if (f.focusdirty() && f.is_edit()) - fe = fe_modify; - } - else - fe = fe_init; - break; - case K_SPACE: - if (!f.is_edit()) - { - if (wm.is_running()) - { - if (f.is_kind_of(CLASS_BUTTON_FIELD)) - fe = fe_button; - else - fe = fe_modify; - } - else - fe = fe_init; - } - break; - case K_ENTER: - fe = fe_close; - break; - case K_F9: - if (f.is_edit()) - fe = fe_button; - break; - default: - fe = fe_null; - break; - } - return fe == fe_null ? TRUE : wm.on_field_event(of, fe, jolly); -} - -bool THandled_mask::universal_notifier(TSheet_field& s, int row, KEY key) -{ - THandled_mask& wm = (THandled_mask&)s.mask(); - TField_event fe = fe_null; - switch (key) - { - case K_INS: - fe = se_query_add; - break; - case K_CTRL+K_INS: - fe = se_notify_add; - break; - case K_DEL: - fe = se_query_del; - break; - case K_CTRL+K_DEL: - fe = se_notify_del; - break; - case K_TAB: - fe = se_enter; - break; - case K_CTRL+K_TAB: - fe = se_query_modify; - break; - case K_ENTER: - fe = se_notify_modify; - break; - default: - break; - } - - return fe == fe_null ? TRUE : wm.on_field_event(s, fe, row); -} - -void THandled_mask::set_handlers() -{ - for (int i = fields()-1; i >= 0; i--) - { - TMask_field& f = fld(i); - if (f.is_operable()) - { - f.set_handler(universal_handler); - if (f.is_sheet()) - ((TSheet_field&)f).set_notify(universal_notifier); - } - } -} - -THandled_mask::THandled_mask(const char* name, int num) - : TMask(name, num) -{ - set_handlers(); -} - -/////////////////////////////////////////////////////////// -// TColumnizer_win +// TColumnizer_win & TColumnizer_field /////////////////////////////////////////////////////////// class TColumnizer_field; @@ -293,7 +144,7 @@ public: void add_column(long col) { col_win().add_column(col); } long get_column(int index) const { return col_win().get_column(index); } - TColumnizer_field(THandled_mask* m) : TWindowed_field(m) { } + TColumnizer_field(TMask* m) : TWindowed_field(m) { } virtual ~TColumnizer_field() { } }; @@ -461,15 +312,11 @@ TColumnizer_win::TColumnizer_win(int x, int y, int dx, int dy, set_scroll_max(columns(), rows()); } -/////////////////////////////////////////////////////////// -// TColumnizer_field -/////////////////////////////////////////////////////////// - /////////////////////////////////////////////////////////// // TWizard_mask /////////////////////////////////////////////////////////// -class TWizard_mask : public THandled_mask +class TWizard_mask : public TAutomask { TRelation* _rel; TRelation_description* _reldesc; @@ -479,7 +326,7 @@ class TWizard_mask : public THandled_mask protected: // TMask virtual TMask_field* parse_field(TScanner& scanner); -protected: // THandled_mask +protected: // TAutomask virtual bool on_field_event(TOperable_field& f, TField_event e, long jolly); protected: // Internal use only @@ -509,9 +356,9 @@ public: // TFields_mask /////////////////////////////////////////////////////////// -class TFields_mask : public THandled_mask +class TFields_mask : public TAutomask { -protected: // THandled_mask +protected: // TAutomask virtual bool on_field_event(TOperable_field& of, TField_event fe, long jolly); protected: // Internal use @@ -586,7 +433,7 @@ bool TFields_mask::field_handler(TOperable_field& of, TField_event fe) } TFields_mask::TFields_mask(const char* name, int number) - : THandled_mask(name, number) + : TAutomask(name, number) { } @@ -610,7 +457,7 @@ public: void describe_fields(); bool handler(TField_event fe, long row); - TFields_sheet(THandled_mask* m); + TFields_sheet(TAutomask* m); virtual ~TFields_sheet(); }; @@ -654,7 +501,7 @@ bool TFields_sheet::handler(TField_event fe, long row) return ok; } -TFields_sheet::TFields_sheet(THandled_mask* m) +TFields_sheet::TFields_sheet(TAutomask* m) : TSheet_field(m), _sheet_mask(NULL) { } @@ -1288,7 +1135,7 @@ TMask_field* TWizard_mask::parse_field(TScanner& scanner) return new TColumnizer_field(this); if (key == "SP") return new TFields_sheet(this); - return THandled_mask::parse_field(scanner); + return TAutomask::parse_field(scanner); } TWizard_mask::TWizard_mask() diff --git a/ba/ba883.cpp b/ba/ba883.cpp index 53dd0ab87..6faba15e9 100755 --- a/ba/ba883.cpp +++ b/ba/ba883.cpp @@ -66,7 +66,8 @@ bool TTab_application::user_create() TString16 m; m << "BATB" << t; _msk = new TMask(m) ; - TString80 tit = _msk->get_caption(); + TString tit; + _msk->get_caption(tit); set_title(tit); return TRUE; @@ -233,9 +234,10 @@ void TTest_application::main_loop() /////////////////////////////////////////////////////////// -class TBenchmark_application : public TApplication +class TBenchmark_application : public TSkeleton_application { clock_t _timer_start; + TString _text; protected: virtual void main_loop(); @@ -281,7 +283,8 @@ void TBenchmark_application::initializing() void TBenchmark_application::start_test(const char* text) { - xvt_statbar_set(text); + _text = text; + xvt_statbar_set(_text); do_events(); clock_t t; @@ -297,20 +300,21 @@ void TBenchmark_application::stop_test() { const clock_t t = clock() - _timer_start; const double s = (double)t / CLOCKS_PER_SEC; - TString80 msg; - msg.format("Time to complete: %.1lf s", s); + TString msg; + msg.format("%s\nTempo totale: %.1lf s", (const char*)_text, s); message_box(msg); } void TBenchmark_application::update_bar(long rec) { - if ((rec & 0x7F) == 0) + rec++; + if ((rec % 500) == 0) { const double sec = double(clock() - _timer_start) / CLOCKS_PER_SEC; if (sec > 0.0) { TString80 msg; - msg.format("%ld records at %ld rec/sec", rec, long(rec / sec)); + msg.format("%ld record (%ld rec/sec)", rec, long(rec / sec)); xvt_statbar_set(msg); do_events(); } @@ -342,8 +346,6 @@ void TBenchmark_application::test_file_scan() void TBenchmark_application::test_relation_scan() { - int found = 0; - initializing(); TRelation comuni(LF_COMUNI); @@ -352,8 +354,6 @@ void TBenchmark_application::test_relation_scan() comuni.first(); for (TRecnotype rec = 0; !comuni.eof(); rec++) { - if (comuni.curr().get("PROVCOM") == "RE") - found++; comuni.next(); update_bar(rec); } @@ -369,9 +369,11 @@ void TBenchmark_application::test_cursor_scan() TRelation comuni(LF_COMUNI); TCursor cur(&comuni); + TRecnotype tot = cur.items(); + cur.freeze(); + start_test("Scansione cursore COMUNI"); - TRecnotype tot = cur.items(); cur = 0L; for (TRecnotype c = 0; c < tot; c++) { @@ -396,7 +398,7 @@ void TBenchmark_application::test_file_random() char code[8]; long found, notfound; - for (long n = 0; n < 1000; n++) + for (long n = 0; n < 4000; n++) { const char l = 'A' + rand() % 26; const int c = rand() % 100; diff --git a/ba/batbban.uml b/ba/batbban.uml index 77ee898f8..fb647b71f 100755 --- a/ba/batbban.uml +++ b/ba/batbban.uml @@ -1,9 +1,8 @@ #include "ba3100.h" #include "batbban.h" -TOOLBAR "" 0 18 0 3 +TOOLBAR "" 0 19 0 3 #include - ENDPAGE PAGE "Tabella banche" -1 -1 78 18