I am trying to increment a status bar to show when something is completed but I am missing the logic. I have a .i
file to do the processing and I wanted the parameters to be passed to that.
First the .i should input from the program with something like
PUBLISH "myStatus" (INPUT mytotal, myrunningcount).
then in each program
I want to
DEF VARIABLE mytotal AS INTEGER NO-UNDO.
DEF VARIABLE myrunningcount AS INTEGER NO-UNDO.
ASSIGN mytotal = 100.
ASSIGN myrunningcount = myrunningcount + 1.
PUBLISH "myStatus" FROM THIS-PROCEDURE(mytotal, myrunningcount).
My expectation is that basically starting right away the status bar grows up to like "ten" records or so right away then resets and grows to ten records until this dataset is loaded. I then want to adapt this to while this "fake" status bar loads i get the real number of records while this is working then display a real percentage of what percent of the data is loaded. Like if there are 10000 records and 5000 are loaded I show 50%. But my attempts have not worked so far.
Thanks for your advice
Peter
First your main program needs to subscribe to your event:
SUBSCRIBE TO "myStatus" IN THIS-PROCEDURE.
Then you run your logic that takes a while to execute. Inside this logic there must be lots of PUBLISH statements.
PUBLISH "myStatus" (INPUT mytotal, myrunningcount).
When the processing is complete you need to unsubscribe.
UNSUBSCRIBE TO "myStatus" IN THIS-PROCEDURE.
You also need to have a procedure called myStatus with 2 input parameters which does the actual status bar update.
PROCEDURE myStatus:
DEFINE INPUT PARAMETER ipimyTotal AS INTEGER NO-UNDO.
DEFINE INPUT PARAMETER ipimyrunningcount AS INTEGER NO-UNDO.
/* update the status bar */
END PROCEDURE.
So in the end when the bulk processing gets done it will publish a lot of myStatus events. Since you've subscribed to the events it will run your local procedure whenever it happens, and in here you do the magic to update your status bar.
What version of OpenEdge are you using?
There are better ways of doing this than include files and classic PUBLISH/SUBSCRIBE statements.
If you're using a more or less recent version of OpenEdge (and that's quite relative) you could create a class that publishes an event, and have a subscriber (can be a procedure or an object) react on that event by incrementing a progress bar.