Clipper53 ACHOICE() 
Author Message
 Clipper53 ACHOICE()

Is there a way of dropping out of an ACHOICE menu if a keypress is not
actioned after a defined time, similar to using INKEY(10) ??

Chris



Sun, 15 Oct 2000 03:00:00 GMT  
 Clipper53 ACHOICE()

On 29 Apr 1998 13:18:33 GMT, "Chris Halling"

Quote:

>Is there a way of dropping out of an ACHOICE menu if a keypress is not
>actioned after a defined time, similar to using INKEY(10) ??

If you have Clipper Tools III, you could use KEYSEC().

--

        Oasis WWW  http://www.iag.net/~philb/
 Oasis WWW Mirror  http://www.enterconnex.com/oasis/
         FTP Site  ftp://ftp.iag.net/pub/clipper

      Everything that is really great and inspiring is
      created by individuals who can labor in freedom.

                                     Albert Einstein



Mon, 16 Oct 2000 03:00:00 GMT  
 Clipper53 ACHOICE()

Dear Chris,

Quote:

> Is there a way of dropping out of an ACHOICE menu if a keypress is not
> actioned after a defined time, similar to using INKEY(10) ??

There is a nice way to do it.
You can use background events: http://www.stack.nl/~lamping/bgevents.htm

Steps:
1. Start an event which scans for time passed.
2. Achoice has the possibility to work in combination with a UDF. Do so.
3. Reset the event timer when a key is pressed using bge_resettimer()

How:

DEFINE EVENT ACTION AChoiceExit NAME "AChoiceExit" Interval 1

Function YourUDF(mode, curel, relpos)
local subretval := 2
local keyp      := lastkey()

do case
  case keyp = 13
    subretval = 1
  case keyp = 27
    subretval = 0
      RELEASE EVENT "AChoiceExit"
  case keyp = 254    // use a key which is different from the ESC char
                     // this way you can see the difference between
                     // a time out and an escape.
    subretval = 0

  case mode = 1
    keyboard chr(CTRL_PGDN)  // scrolling achoice
  case mode = 2
    keyboard chr(K_CTRL_PGUP)  // scrolling achoice
  case mode =

  otherwise
    * do nothing
endcase

BGE_ResetTimer( "AChoiceExit")
if subretval = 0
  RELEASE EVENT "AChoiceExit"
Endif
Return subretval

Function AChoiceExit()
   // Function beginning with BGE_ are part of the bgevents system
   // and so is dseconds()

   If bge_dtimer( "ACHOICEEXIT" ) - Dseconds() > 10

      keyboard chr( 254 )  // YOURUDF() reacts on this key.

      // The event has done its work. Release it now.
      RELEASE EVENT "AChoiceExit"
   Endif
   Return Nil

Remarks:
Remind that whatever way you choose, KEYSEC() in CA-TOOLS III or
bgevents. The key or event will be fired after 10 seconds of none
actions. Using an 'achoice-UDF' you have the possibility to launch any
function from within the UDF. If you do so, the key or event will still
be launched. With bgevents you have the possibility to deactivate the
event before doing something else and then reset its timer following by
reactivation of the event.

    case pkey = asc( "P" )
       * e.g. print something which takes longer than 10 seconds.
      DEACTIVATE EVENT "AChoiceExit"  

      yourprintfunction()      

      BGE_ResetTimer( "AChoiceExit")  // reset timer before reactivation
      ACTIVATE EVENT "AChoiceExit"

      * now you don't have the risk of a keyboard chr(254) being fired.

    case ..

Kind regards,

Robert Lamping
Creator of Background Events



Wed, 25 Oct 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Clipper53 on Win98...Another one

2. How to use *.FNT font in llibg.lib in Clipper53

3. Clipper 53->53a->53b Update-ActualizaciĆ³n Clipper53->53a->53b

4. AChoice & a multi dim array

5. achoice and graying out unselectable items

6. achoice with two dimensional arrays

7. Achoice Equivalent GUI box RUN under Hybrid Mode

8. extending ACHOICE()

9. Achoice great feature in dbedit

10. Use mouse with achoice

11. Can I have different color in achoice()

12. I have Achoice() Problems who can help me !!!!!!

 

 
Powered by phpBB® Forum Software