Flash a Message

Started by Jeffrey Ferreira, January 25, 2024, 02:15:21 PM

Previous topic - Next topic

Jeffrey Ferreira

Hi All

is there a way to flash a message on the screen in a multiline and then clear it after a few seconds.
i was going to implement with the timeout but i thought i would ask if there was a more sophisticated way to do this.
i'm trying to avoid adding message boxes.

thanks

jeff

Cees Trip

I don't know if this helps but I used listed code in several programs to draw attention to mandatory fields:

00010  LET ML=100
00011  MULTI_LINE ML,@(20,10,32,6),FNT="Arial,-13,B"
00020  LET TXT_OLD$="** this is the old text ** this is the old text ** this is the old text **"
00030  MULTI_LINE WRITE ML,TXT_OLD$
00040 !
00041 OBTAIN:
00042  OBTAIN *
00050 !
00060  IF CTL=1 \
        THEN GOSUB TXT_MSG0
00061  IF CTL=4 \
        THEN GOTO END1
00070  GOTO OBTAIN
00071 TXT_MSG0:
00080  LET TXT_OLD$=ML'VALUE$ ! save existing text
00081  LET BC_OLD$=ML'BACKCOLOR$
00090  LET TMP0=0,TMP1=3,TXT_MSG$="example text example text example text example text example text example text"
00110 TXT_MSG1:
00111  LET ML'VALUE$=TXT_MSG$,ML'BACKCOLOR$="RGB: 255 75 43" ! write message
00120  WAIT 1
00121  LET ML'BACKCOLOR$="RGB: 255 255 0",ML'VALUE$=TXT_MSG$
00122  WAIT 1
00130  LET TMP0+=1
00140  IF TMP0<TMP1 \
        THEN GOTO TXT_MSG1
00150  LET ML'VALUE$=TXT_OLD$,ML'BACKCOLOR$=BC_OLD$ ! write back original text and backcolor
00160  RETURN
00170 END1:
00180  END
- personal is not the same as important - Terry Pratchett

Loren Doornek

Jeff, if you're using Nomads, you might be able to do this with a Dependency Definition.  The dependencies are very good at checking everything and updating the screen as needed anytime the user interacts with the screen.  I'd prefer the dependency since I hate to just put a WAIT on the message, since that prevents the user from doing anything for the entire WAIT time.  Displaying a message using a dependency would allow the user to continue working, and the message would just clear once Nomads had to do anything after the specified time had expired.  If the user didn't interact with the screen until long after the time had expired, the message would still be displayed since nothing happened to trigger the dependency checks.  You could get around this by adding a timeout check to the screen.  Leaving the message on the screen until the user interacts with the screen again might not be a bad idea, since it gives an indicator of what the user was doing before they took a long pause.

For example, I created a panel with several controls, including a multiline named ML1, a multiline named FLASH, and a checkbox named CHK1.  There is no logic associated with any of the controls.  I then added a dependency as shown below:

Condition=flashtim>0 or not(nul(ml1$))
Invert=N
Depend Logic=Execute tn=(jul(0,0,0)*86400)+num(dte(0:"%S"));if tn>flashtim then flash$=$$,flashtim=0 end_if;if not(nul(ml1$)) then let flash$=ml1$,flashtim=tn+5,ml1$=$$

When processing the screen, any text entered into the ML1 box will be displayed in the FLASH box for a minimum of 5 seconds, unless ML1 is changed to something else.  After 5 seconds, FLASH will be cleared as soon as Nomads does anything.  Almost any interaction with the screen (even just tabbing between controls, or clicking on the checkbox CHK1 even though it has no logic) will cause Nomads to check the dependencies, and reset the flash message if the time has expired.  As noted, you could also set a timeout of 5 seconds on the Nomads screen if you really wanted the message to be cleared after 5 seconds even if the user wasn't interacting with the screen.

Mike King

Jeff,

Perhaps the easiest solution if you are using Nomads is to set a timeout value to invoke code to hide/clear the message.

For example, when you display the message set %nomads'timeout to the number of seconds you want the message to remain.  The timeout will cause the system to attempt to close your panel so in the panel wrap up logic test if CTL = -1900 (panel timeout); if its a panel timeout clear the message, reset %nomads'timeout to 0, and set IGNORE_EXIT to 1. 

If you already have timeout logic in your panel you may want to set another variable as well when you display the message to indicate that the timeout is to handle clearing the message.
Mike King
President - BBSysco Consulting
eMail: mike.king@bbsysco.com

Jeffrey Ferreira

Thank you for all the ideas. I will implement one of them.  I just wanted to make sure I wasnt missing something like a call back feature like in javascript.  I saw background loading of controls and that made me think that perhaps something like a call back could be present. I appreciate every ones ideas. thank you.