====== Displaying Dynamic Text Using OpenInsight's MSG Function (Functions/Subroutines/Programs) ====== ====== ====== ==== Created at 07 FEB 2003 03:29PM ==== We know that OpenInsights flexible MSG function allows you construct messages dynamically.  One of its most useful features is available to the developer by using a Gas Gauge or GC type message.  The Gas Gauge type message can be constructed as outlined in the MSG_EQUATES record in INSERTS.  A message created using the  GC  parameter will display a gas gauge, or progress bar, as part of the message.   Parameters are passed to the message and the ticks on the progress bar are updated as processing occurs.  Coding it is a fairly straight forward affair as outlined in the MSG_EQUATES record (see example below).   *** to display a gauge (percent bar),use the "G" type; sub-types are C (show** *** cancel button) and Y (yield on each cycle):** **          Declarefunction MSG** **          Declaresubroutine MSG** **          $Insert INSERTS, MSG_Equates** ****   **   Def = ""** **   Def = "ProcessingOrders..."** **    Def = "GC"** **   Def = OrderCnt** **   MsgUp = Msg(@window, Def)** **   for Order = 1 to OrderCnt** **        gosub ProcessOrder** **  *   update the gauge and check if cancel was pressed** **       while Msg(@window, MsgUp, Order, MSGINSTUPDATE$)** **   next Order** **   Msg(@window,MsgUp)        ;* take down the gauge** ****   Recently,we needed to display a message showing the percentage of records processed in addition to the standard gas gauge progress bar.  Displaying the message and bringing it back down does not offer satisfactory results because of the annoying screen flicker associated with this method.   Amore elegant approach to use is to manipulate the text property of MSG s  ST_TEXT control.  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 properties of the available MSG controls can be viewed by selecting  **Inspect Properties**  from the  **Variables**  menu in the OpenInsight Debugger.  Select  MSG  from the  **Window Name**  combo box.  The list of available controls with be displayed in the  **Control Name**  combo box.  The  ST_TEXT control is the one that contains the text property displayed on the message.  A list of its properties is available from the  **Property**  combo box. This particular control and this property continue to be available even as multiple instances of standard messages are being displayed.   These other messages can be called within the process that is updating the gas gauge message.  OI will keep track of them for you while you manipulate your gas gauge message.  Types of messages tested while running the process shown below included timed messages (T1), standard application type (A) messages, and processing messages(UB and DB).  These all functioned as specified.  The gas gauge continued to update as records were being processed.   Below is an example of the code that displays the gas gauge message along with a percentage of the records processed. **            Declarefunction MSG, Set_Property** **            Declaresubroutine MSG** **            $Insert INSERTS, MSG_Equates** ****   **   Def =  ""** **   Def= "Generating New Invoices"** **   Def = "GC"** **   Def = @reccount ** **   YOURTEXT = '% of theNew Invoices Completed'** **  Def = YOUR TEXT** **  Def = 200** **   MsgUp= Msg(@window,Def)** **   totrecs = @reccount** **   cnt= 0** **   Loop** **        Readnext @ID Else EOF = 1** **   Until EOF** **        Read @Record from invoice_file, @ID Then               ** **             cnt += 1                          ;*increment  counter for gas gauge** **             recs = int(totrecs/20)** **             If Mod(cnt,recs) = 0 Then** **            * so forevery 20 records** **                 pct= INT((cnt/totrecs) * 100)** **                 If pct > 100 then pct = 100** **                YOURVAR = pct  : YOURTEXT** **             End** **             Gosub Process_Invoice** **              X = SET_PROPERTY('MSG.ST_TEXT','TEXT',YOUR VAR)   ** **         End Else** **               Msg('Unable to read %1%','','',@ID)** **         End** **   while Msg(@window, MsgUp, CNT,MSGINSTUPDATE$, '')** **   Nextcrs:Repeat** **   Msg(@window, MsgUp)         ;* take down the gauge                ** **   Return** ****   By taking advantage of OpenInsight s flexibility and adding your own creativity, Windows-based rapid application development is no longer what we aspire to  it s here, now, and available to you, the OI developer.