Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

A useful enhancement to the standard gas gauge progress bar is to change the message, showing, for example, percent of records processed.  Raising Raising the message with the changed text and then lowering it does not offer satisfactory results because of the annoying screen flicker associated with this method.

A more elegant approach to use is to manipulate the TEXT property of the MSG window ST_TEXT control.  The The Msg() function is actually updating a window called MSG.  The The MSG window has its own controls, including the ST_TEXT control.  By By loading the percentage variable along with its accompanying text into a second variable and then setting the control's TEXT property to this second variable, we can update the gas gauge message without the screen flashing every time we raise and lower the message.

...

The code below assumes that the INVOICE table is read completely.  The The number of rows in the table, used as the denominator for the percentage of rows read, is retrieved using the Get.RecCount() function.  To To prevent the invoice processing from slowing down unnecessarily, we want the percentage calculation and message update to occur only after 20 invoices have been processed.  The The code below illustrates how this can be accomplished:

 

Code Block
declare function msg , get.reccount
declare subroutine fsmsg
$Insert msg_equates
$insert logical
open 'ORDERS' to orders_file else
   fsmsg()
   return 1
end
select orders_file
totrecs = get.reccount(orders_file, flag, 0)
if flag else
   /* unable to get record count - process error */
end
Def = ""
Def<MCAPTION$> = "Generating New Invoices"
Def<MTYPE$ > = "GC"
Def<MEXTENT$ > = totrecs
YOURTEXT = '% of the New Invoices Completed'
Def<MTEXT$> = YOURTEXT
Def<MTEXTWIDTH$> = 200
MsgUp = Msg(@window, Def)
 
cnt = 0
EOF = FALSE$
Loop
Readnext @ID Else EOF = TRUE$
Until EOF
   Read @Record from orders_file, @ID Else
     retval = Msg('Unable to read %1%','','',@ID)
     Goto Nextcrs
   End
   cnt += 1 ;*increment counter for gas gauge
   recs = int(totrecs/20)
   If Mod(cnt,recs) = 0 Then
     * so for every 20 records
     pct= INT((cnt/totrecs) * 100)
     If pct > 100 then pct = 100
     YOURVAR = pct : YOURTEXT
   End
   Gosub Process_Invoice
   while Msg(@window, MsgUp, CNT, MSGINSTUPDATE$, '')
     /* update the message with the new percentage completion here */
     X = Set_Property('MSG.ST_TEXT','TEXT',YOURVAR)
Nextcrs: Repeat
retval = Msg(@window, MsgUp) ;* take down the gauge
Return 0
 
process_invoice:
*
*  do the invoice processing here...
*
return