is there a way to avoid program abortion if EXIT-KEY pressed
Author
Message
Ford Prefect
Senior Roboticist
Joined: Sat Mar 01, 2008 12:52 pm Posts: 936 Location: a small planet in the vicinity of Beteigeuze
is there a way to avoid program abortion if EXIT-KEY pressed
hello,
is there a way to avoid program abortion if Exit Key is pressed?
I want the program to continue although the Exit Key is pressed,
but if I wrote
Code:
nNxtButtonTask=1;
this command line is completely ignored...
Code:
#define println nxtDisplayTextLine
char getch(){
TButtons nBtn; nBtn = nNxtButtonPressed; // check for button press
switch (nBtn) { case kLeftButton: { return 1; break; }
case kRightButton: { return 2; break; }
case kEnterButton: { return 3; break; }
case kExitButton: { return 4; break; }
default: { return 0; break; } } }
int key=-1;
task main() { eraseDisplay(); nNxtButtonTask=1; // program exits anyhow! while (true) { key=getch(); println(1,"Key= %d",key); wait1Msec(50); } }
Thx in advance!
_________________ Ford Prefect
Never purchase release 1.x ! (ancient programmer's wisdom) "Don't argue with idiots. They'll drag you down to their level and then beat you with experience."
Last edited by Ford Prefect on Sun Apr 27, 2008 4:37 am, edited 2 times in total.
Sat Apr 26, 2008 10:23 am
Koldo
Rookie
Joined: Sun Aug 12, 2007 3:18 pm Posts: 38
Hello
You can use nNxtExitClicks variable
"Holds the number of 'clicks' of the EXIT button required to abort a program. Default value is one for compatibility with standard firmware.
This variable allows end user programs to use the EXIT button. If you set the variable to 'N' (where 'N' is greater than 1) then the first 'N-1' consecutive clicks of the EXIT button can be handled by the application program. On the N-th consecutive click the firmware will automatically EXIT (i.e. end) your program.
Having the firmware perform the check ensures that, even if there is an error in your program, you can always EXIT your program. But it also easily allows your program to have access to the EXIT button."
http//Lrobotikas.net
Sat Apr 26, 2008 11:42 am
Ford Prefect
Senior Roboticist
Joined: Sat Mar 01, 2008 12:52 pm Posts: 936 Location: a small planet in the vicinity of Beteigeuze
hi,
I added
nNxtExitClicks=500; and it works just as you wrote!
thx a lot!
_________________ Ford Prefect
Never purchase release 1.x ! (ancient programmer's wisdom) "Don't argue with idiots. They'll drag you down to their level and then beat you with experience."
Users browsing this forum: No registered users and 6 guests
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum