This can be implemented with the following UserFunction, 

named PopDelay(): 



+------------------------------------------------------------------+

| UserFunction PopDelay |

+------------------------------------------------------------------+

| |

| +------+ +-----------------+ |

| | now()+-->| Set Global: T0 | Get time zero for delay |

| +------+ +--------+--------+ calculation |

| | |

| +------+ +--------+--------+ |

| | 0 +-->| Set Global: PF | Clear flag to indicate |

| +------+ +--------+--------+ toggle set. |

| | |

| +---+---+ |

| | Until | |

| | Break +--+ |

| +-------+ | |

| | |

| +----+----+ |

| reset +-->| Button +---+ toggle control |

| | +---------+ | |

| +-----------------+-----------------+ |

| | |

| | +----------------------------------------+ |

| | | If/Then/Else | |

| | +--+---------------------------+---------+ |

| | | | (PF==0) AND (now()-T0 > 5)| Then +---------+ |

| +-->| A| (PF==0) AND (A==1) | Else If +------+ | |

| | | (PF==1) AND (A==1) | Else If +--+ | | |

| +--+---------------------------+---------+ | | | |

| | | | |

| +---------------------------------------+ | | |

| | | | |

| | +--------------+ | |

| | | | |

| +------+------+ +----+ +--------+--------+ +------+------+ |

| | Exit | | 1 +-->| Set Global: PF | | Exit | |

| | UserObject | +----+ +-----------------+ | UserObject | |

| + ------------+ +-------------+ |

| |

+------------------------------------------------------------------+

 

The important features of this UserFunction are as follows: 


This UserFunction has a Panel View that consists solely of the 

Button. The UserFunction is set to Show Panel On Execute. 


The keys are two Global Variables, T0 (Time-Zero) and PF (Program 

Flag). T0 gives the initial time when the UserFunction is invoked. 

PF specifies if the user has clicked on the UserFunction panel''s 

button (1) or not (0). For VEE 4.0 or later, it is appropriate to 

define Local Variables instead. 



When the UserFunction is invoked, it sets the initial time into T0 

(using the now() function) and sets PF to 0 (button not pushed). 


It then goes into a loop, continuously sampling the value of the 

Button. This is normally 0; it will go to 1 if the user clicks on it 

(and then reset itself back to the zero state with its feedback 

wiring). 


This value is fed into an If/Then/Else, which is the core logic of 

the program. It has three statements: 


The first checks to see if PF is 0 (button not pushed), and then 

subtracts T0 from now() to see if the interval has elapsed (I hard-

coded it to 5 seconds in this example, but a variable could be used 

instead). If both conditions are true, the UserFunction exits. 


The second checks to see if PF is 0 and the Button input is 1. If 

so, this means that the Button hasn''t been pushed before and has now 

been set -- and the UserFunction sets PF to 1. The third checks to 

see if PF is 1 and the Button input is 1. If so, this means that the

Button has been pushed before and has now been set -- and the 

UserFunction exits. 


 


Copyright (c) 1991-1999 Hewlett-Packard Company

 


Revision 1.0 22 Dec 99 djf