ROBOTC.net forums
http://robotc.net/forums/

is there a way to avoid program abortion if EXIT-KEY pressed
http://robotc.net/forums/viewtopic.php?f=1&t=532
Page 1 of 1

Author:  Ford Prefect [ Sat Apr 26, 2008 10:23 am ]
Post subject:  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!

Author:  Koldo [ Sat Apr 26, 2008 11:42 am ]
Post subject: 

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

Author:  Ford Prefect [ Sat Apr 26, 2008 6:48 pm ]
Post subject: 

hi,
I added
nNxtExitClicks=500; :wink:
and it works just as you wrote!
thx a lot!

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/