Asynchronous alert

T

* Tong *

Hi,

I'm trying to write an alert detection script.

Generally, the script loops to detect if the alert criteria is met,
and if so, alert the user. Somewhat like this:

for(;;){
my $alerted;
my $flag=detect_flag
if($flag){
alert_user unless $alerted;
$alerted=1
}
}

The 'alert_user' can be as simple as a pop up window via Xdialog. Once the
alert goes off, it might take some time to resolve, but I don't want to
alert user again and again, hence the '$alerted' var. The problem is that
I need a way to clear the '$alerted' var. I think, to make it simple, the
best time is when the user confirm the alert pop up window.

Now, what's the easiest way to do it? The reason I wanted to use Xdialog is
because it's extreme easy to code, but I can't think of a way to clear the
'$alerted' var.

please help

thanks a lot
 
T

* Tong *

my $alerted;
for(;;){
my $flag=detect_flag
if($flag){
alert_user unless $alerted;
$alerted=1
}
}
Most probably, making $alerted a package variable will do it. You might
also be able to solve the problem by putting "my $alerted" above the for
loop.

thanks for the suggestion. please see above. Please note that, what I need
is the simplest solution.
Since the program you posted is not complete, it's hard to comment
further.

IMHO, as a *general purpose* *high-level* code snip, it is complete. What
only lacks is the way/mechanism to reset $alerted asynchronous, which I
don't know and is asking -- how to reset it determines how the alert_user()
is coded, and there is no need to dive into the detect_flag() at all.

thanks
 
G

Guest

Hi,

I'm trying to write an alert detection script.

Generally, the script loops to detect if the alert criteria is met,
and if so, alert the user. Somewhat like this:

for(;;){
my $alerted;
my $flag=detect_flag
if($flag){
alert_user unless $alerted;
$alerted=1
}
}

The 'alert_user' can be as simple as a pop up window via Xdialog. Once the
alert goes off, it might take some time to resolve, but I don't want to
alert user again and again, hence the '$alerted' var. The problem is that
I need a way to clear the '$alerted' var. I think, to make it simple, the
best time is when the user confirm the alert pop up window.

Now, what's the easiest way to do it? The reason I wanted to use Xdialog is
because it's extreme easy to code, but I can't think of a way to clear the
'$alerted' var.

please help

thanks a lot

Most probably, making $alerted a package variable will do it. You might
also be able to solve the problem by putting "my $alerted" above the for
loop.

Since the program you posted is not complete, it's hard to comment further.

Posting Guidelines for comp.lang.perl.misc:
http://www.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
 
G

Guest

my $alerted;

Doh! How did I miss that?
for(;;){
my $flag=detect_flag
if($flag){
alert_user unless $alerted;
$alerted=1
}
}


thanks for the suggestion. please see above. Please note that, what I need
is the simplest solution.


IMHO, as a *general purpose* *high-level* code snip, it is complete. What
only lacks is the way/mechanism to reset $alerted asynchronous, which I
don't know and is asking -- how to reset it determines how the alert_user()
is coded, and there is no need to dive into the detect_flag() at all.

thanks

Under what conditions do you want to clear the $alerted flag?
 
T

* Tong *

Under what conditions do you want to clear the $alerted flag?

I think, to make it simple, the best time is when the user confirm the
alert pop up window -- i.e., user click, pop up gone, $alerted cleared.

how is that?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top