IB Statements/SetTimer

From CometWiki

< IB Statements
Revision as of 20:03, 22 July 2010 by Jim (Talk | contribs)
Jump to: navigation, search

Introduction

There are many times that you may want to get some information from the user but there are records extracted, or some other reason that would mess things up if the user did not provide the information in a timely manor.

With the SetTimer statement, you can limit the time a user has to input the info, and take some action.

Syntax:
SetTimer TimerName, Duration

Where TimerName is a string expression and Duration is a numeric expression.

Discussion:

The SetTimer instruction causes an event to be fired to the program when a specified duration (in Milliseconds) has passed.In the event handler, the program has the opportunity to do several things.

  • Stop execution
  • Warn the user
  • Using the SatisfyInput command, supply a default response

SetTimer will fire from an Input statement, Wait statement, or EventWait statement.

To stop the timer, use the following:

 SetTimer "", 0
Example:
Length 254 & Local EventSource$, EventName$
length 80 & local a$
Length 5.0 & Local Count
 Clear
 Print (cs)
 EventSub TimerFunc EventSource$ EventName$
 SetTimer "Timer 1: "+Term$, 10*10*10   ! One Second
 print @(0,9);'enter something'
 input @(1,10) a$
 if a$ = "" goto EndIt
 print @(0,10);(cfld);@(0,11);'you entered ';a$
 Loop
EndIt:
  SetTimer "", 0
  EventSub
  print @(0,15);'done' & wait
 Stop
TimerFunc:
  Count = Count + 1
  Print (mc);@(0,5);(rb);"Source: " ; EventSource$ ; " Event: " ; EventName$ ; "(";Count;")";(rc)
  EventSub TimerFunc EventSource$ EventName$
 Return


Personal tools