"BR closing" event

General development discussion.

Moderators: Susan Smith, admin, Gabriel

Post Reply
Mikhail
Posts: 87
Joined: Tue Jul 07, 2009 10:26 am
Location: Ukraine

"BR closing" event

Post by Mikhail »

We have the "BR start" event, sort of, in the form of being able to run a program when BR starts. It would be great if we had a "BR closing" event. For example, I want to log out the user if they abnormally terminate a program.
Gabriel
Posts: 412
Joined: Sun Aug 10, 2008 7:37 am
Location: Arlington, TX
Contact:

Post by Gabriel »

Fkey 93 indicates this event in BR. It is triggered when they click on the windows X and its also triggered when they use task manager to end the brnative task. You'll want to respond to this fkey value, log the user out and then execute "sy" to close BR.

In ScreenIO, you have the "Exit Event", and you can place the "log out" code in your exit event of your screens, and ScreenIO will make sure to call it whenever the screen is exiting.

Gabriel
Larry TIetz

Post by Larry TIetz »

How do I capture this key stroke? I have a client who sometimes clicks the x(close) in the middle of things, rather than exiting via the menu system. I don't capture every keystroke, but do check entries after exiting a field or selecting a menu item.

This is a problem because periodically selecting the x (close) freezes the program. I haven't been able to duplicate the situation on a regular basis on his system, or mine at all. I thought it might disappear with the latest version of BR but that didn't do the trick.
Gabriel
Posts: 412
Joined: Sun Aug 10, 2008 7:37 am
Location: Arlington, TX
Contact:

Post by Gabriel »

Check after your input fields statements for an fkey value of 93 and make it do the same thing that selecting "Close" in your menu does.

gabriel
gtisdale
Posts: 218
Joined: Sun Jun 07, 2009 7:54 am
Location: Concord, Massachusetts
Contact:

Post by gtisdale »

You can also put in a "universal trap" in your programs with an on fkey event trap.

For example:

01000 ON FKEY 93 GOTO KEY93
01010 RINPUT FIELDS '10,10,v 2': A$
01020 IF FKEY=99 THEN STOP
01030 GOTO 1010
01040 KEY93: PRINT FIELDS "11,10,c ": "Fkey 93 was pressed"
01050 GOTO 1010

Note that on FKEY was recently changed, it used to be on FNKEY, but that became confusing since only fnuctions are supposed to start with FN

FNGeorge
John
Posts: 555
Joined: Sun Apr 26, 2009 8:27 am

Post by John »

:?: Does this work for you, George?

:shock: According to http://brwiki.ads.net/index.php?title=E ... Y_num-expr this will only work for fkeys 1-10. Not 93.

8) It'd be nice if 99 and 93 would work during processing - then we could actually code a mid process cancel/close option. And then goodbye non-responsive program.

-John
gtisdale
Posts: 218
Joined: Sun Jun 07, 2009 7:54 am
Location: Concord, Massachusetts
Contact:

Post by gtisdale »

Try the imbedded program. It does work, regardless of what the Wiki says.
John
Posts: 555
Joined: Sun Apr 26, 2009 8:27 am

Post by John »

oh wow - It does work! The wiki also said that On FKey won't work at input statements... but your sample clearly demonstrates that it does!!! This opens up a whole new world of possibilities!

I'm going to try it during processing too...
John
Posts: 555
Joined: Sun Apr 26, 2009 8:27 am

Post by John »

further...

00100 pr newpage
01000 ON FKEY 93 GOTO KEY93
01002 ON FKEY 99 GOTO XIT
01022 do
01024 sleep(.1)
01026 pr f '1,1,G 20':x+=1
01028 loop
01040 KEY93: PRINT FIELDS "11,10,c ": "Fkey 93 was pressed"
01050 GOTO 1022
01060 XIT: END

proves that both F93 and F99 will work during processing not being at an input. using these ON FKEY 93 and ON FKEY 99 statements can give your program program wide close and escape behavior! During processing, at Inputs, etc.

I do believe we're on our way to event based processing!!!! YAY!!!

Thanks for the eye-opener, George!!!

-John :D
gtisdale
Posts: 218
Joined: Sun Jun 07, 2009 7:54 am
Location: Concord, Massachusetts
Contact:

Post by gtisdale »

Remember also that with the latest version you can also do

ON FKEY 93 gosub 93key

as well as

ON FKEY 93 goto 93key
Larry TIetz

Post by Larry TIetz »

and....

what is the latest version?
Mikhail
Posts: 87
Joined: Tue Jul 07, 2009 10:26 am
Location: Ukraine

Post by Mikhail »

What I'm talking about is a global BR_closing event, which always gets triggered before BR quits.

Maybe, adding

on BR_closing run logout.br

into your wbconfig.sys

This way we wouldn't have to add code to each of our programs.

I guess there is no such thing now, but it wouldn't be difficult to implement in future versions of BR.
GomezL
Posts: 258
Joined: Wed Apr 29, 2009 5:51 am
Contact:

Post by GomezL »

OPTION 54 is OFF - exit at command prompt

This is a very nice option that will force BR to shut down if your program ever stops.

It's a "Hard Shutdown" with a notice to the user.
Post Reply