Show indexing progress

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

cocoking
Posts: 46
Joined: Tue Jun 15, 2010 1:15 pm
Location: Malabang, Lanao del Sur

Show indexing progress

Post by cocoking »

Please find time to examine my code.

With the codes below, EditBox is shown after Activate Window, thus index progress is not real-time. With too many files and too many records, display will be blank for a long time before EditBox is shown.

My intention is to show the editbox and update display after every file is indexed. How do I do it?
function Reindex()

DECLARE WINDOW MainForm

DEFINE WINDOW fmReindex ;
AT 10, 10 ;
WIDTH 336 ;
HEIGHT 310 ;
TITLE "Reindexing Files" ;
MODAL

@ 10, 10 EDITBOX ebRein ;
PARENT fmReindex ;
WIDTH 300 ;
HEIGHT 300 ;
VALUE "Reindexing files..." + CRLF ;
READONLY

ON KEY ESCAPE OF fmReindex ACTION fmReindex.Release

END WINDOW

// indexing codes are here

use file1
index on field1 to file1
fmReindex.ebRein.Value := fmReindex.ebRein.Value + "File1..." + CRLF

use file2
index on field2 to file2
fmReindex.ebRein.Value := fmReindex.ebRein.Value + "File2..." + CRLF

// other files are indexed here...

CENTER WINDOW fmReindex
ACTIVATE WINDOW fmReindex

return NIL
I thought of transferring all indexing codes below the Activate Window command and adding a .show, such as this:
...
CENTER WINDOW fmReindex
ACTIVATE WINDOW fmReindex

use file1
index on field1 to file1
fmReindex.ebRein.Value := fmReindex.ebRein.Value + "File1..." + CRLF
fmReindex.ebRein.show
...
but I get an error: Control: ebRein of fmReindex not defined. Program terminated.

Any ideas?
User avatar
Rathinagiri
Posts: 5482
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Show indexing progress

Post by Rathinagiri »

Please try this:

Code: Select all

function Reindex()

DECLARE WINDOW MainForm

DEFINE WINDOW fmReindex ;
AT 10, 10 ;
WIDTH 336 ;
HEIGHT 310 ;
TITLE "Reindexing Files" ;
MODAL On INIT indexfiles()

@ 10, 10 EDITBOX ebRein ;
PARENT fmReindex ;
WIDTH 300 ;
HEIGHT 300 ;
VALUE "Reindexing files..." + CRLF ;
READONLY

ON KEY ESCAPE OF fmReindex ACTION fmReindex.Release

END WINDOW

CENTER WINDOW fmReindex
ACTIVATE WINDOW fmReindex

return NIL

Function indexfiles
// indexing codes are here

use file1
index on field1 to file1
fmReindex.ebRein.Value := fmReindex.ebRein.Value + "File1..." + CRLF

use file2
index on field2 to file2
fmReindex.ebRein.Value := fmReindex.ebRein.Value + "File2..." + CRLF

// other files are indexed here...


Return Nil
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
cocoking
Posts: 46
Joined: Tue Jun 15, 2010 1:15 pm
Location: Malabang, Lanao del Sur

Re: Show indexing progress

Post by cocoking »

Rathi, thank you for your suggestion. Unfortunately it did not work as intended. Using Trace Debug, I found that the editbox's contents ("File1", "File2"...) were written only after all files were indexed (after finishing the Indexfiles function).

I tried to add fmReindex.ebRein.show after each file, no difference.

I tried to add fmReindex.ebRein.refresh after each file, then I get an Argument error: & on the first file indexed (File1):
Error BASE/1065 Argument error: &
Called from _DATAEDITBOXREFRESH(237)
Called from _REFRESH(3686)
Called from _DOMETHOD(7446)
Called from REINSYSFILES(176)
...
Please note that ReinSysFiles(176) is the fmReindex.ebRein.refresh command.

Looking at the display, however, the ebRein window showed "File1..."

Was it updating ebRein (as intended) when it had an Argument error?

Please help. Or would you prefer/recommend another way of showing the indexing progress?

TYVM
mrduck
Posts: 497
Joined: Fri Sep 10, 2010 5:22 pm

Re: Show indexing progress

Post by mrduck »

cocoking wrote:Rathi, thank you for your suggestion. Unfortunately it did not work as intended. Using Trace Debug, I found that the editbox's contents ("File1", "File2"...) were written only after all files were indexed (after finishing the Indexfiles function).
You must give windows the time to process your request...

Try adding
DO EVENTS
after the
fmReindex.ebRein.value :=
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Show indexing progress

Post by esgici »

Hi Cocoking

Please look at this :

download/file.php?id=1439

Regards

--

Esgici
Viva INTERNATIONAL HMG :D
User avatar
Rathinagiri
Posts: 5482
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Show indexing progress

Post by Rathinagiri »

Thanks for the link Esgici. :)
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
cocoking
Posts: 46
Joined: Tue Jun 15, 2010 1:15 pm
Location: Malabang, Lanao del Sur

Re: Show indexing progress

Post by cocoking »

Thank you for joining, esgici, however, the attachment does not exist anymore.
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Show indexing progress

Post by esgici »

Hi Cocoking,

I re-downloaded and re-attached here.

The .rar file shown in the "Portal Index" page of forum.

I hope that it will help you.

Regards

--

Esgici
IndxPrgss.rar
Solution for Index Progress problem sent by Cocoking
(2.89 KiB) Downloaded 323 times
Viva INTERNATIONAL HMG :D
cocoking
Posts: 46
Joined: Tue Jun 15, 2010 1:15 pm
Location: Malabang, Lanao del Sur

Re: Show indexing progress

Post by cocoking »

Thank you for the help. Unfortunately, I did not get what I intended to do (similar to progress bar):

Several files are automatically indexed; as files are indexed, editbox should update as follows:

as 1st file is indexed, editbox should show --> File1
as 2nd file is indexed, editbox should show --> File1, File2
as 3rd file is indexed, editbox should show --> File1, File2, File3
as 4th file is indexed, editbox should show --> File1, File2, File3, File4
...
as nth file is indexed, editbox should show --> File1, File2, File3, File4... FileN

What happens is, the indexing is already finished when the editbox is updated. If several big files are involved, screen would show no activity for a long time (waiting for the indexing to be finished), before the editbox is updated. It is not like a progress bar at all.

Tracing thru the programs (using altd() function), I discovered that the windows/objects display are updated only when the end of the event loop is reached (the ACTIVATE WINDOW command).

Please teach me how to force the screen update/refresh (programatically, without user intervention) before the ACTIVATE WINDOW command, if at all possible.

TYVM
mrduck
Posts: 497
Joined: Fri Sep 10, 2010 5:22 pm

Re: Show indexing progress

Post by mrduck »

cocoking wrote: Please teach me how to force the screen update/refresh (programatically, without user intervention) before the ACTIVATE WINDOW command, if at all possible.
I don't think it is possible since the window is not activated
You have two ways:
1) create the first MODAL window with one editbox/progressbar and in its ON INIT procedure do the indexing; as last line force window closing; then open the window you need to work in

2) create the window as you do now; you need to run the indexing in the ON INIT procedure if you want to visually change the editbox value... and you should call "do events" if you want that windows updates the display
Post Reply