IB Statements/SetTimer

From CometWiki

(Difference between revisions)
Jump to: navigation, search
m (minor)
m (minor)
Line 38: Line 38:
   SetTimer "Timer 1: "+Term$, 10*10*10  ! One Second
   SetTimer "Timer 1: "+Term$, 10*10*10  ! One Second
   print @(0,9);'enter something'
   print @(0,9);'enter something'
-
   input @(1,10) a$
+
   Do
-
  if a$ = "" goto EndIt
+
    input @(1,10) a$
-
  print @(0,10);(cfld);@(0,11);'you entered ';a$
+
    if a$ = "" goto EndIt
 +
    print @(0,10);(cfld);@(0,11);'you entered ';a$
   Loop
   Loop
Line 47: Line 48:
   EventSub
   EventSub
   print @(0,15);'done' & wait
   print @(0,15);'done' & wait
-
  Stop
+
Stop
  TimerFunc:
  TimerFunc:
Line 53: Line 54:
   Print (mc);@(0,5);(rb);"Source: " ; EventSource$ ; " Event: " ; EventName$ ; "(";Count;")";(rc)
   Print (mc);@(0,5);(rb);"Source: " ; EventSource$ ; " Event: " ; EventName$ ; "(";Count;")";(rc)
   EventSub TimerFunc EventSource$ EventName$
   EventSub TimerFunc EventSource$ EventName$
-
  Return
+
Return
</td>
</td>
</table>
</table>

Revision as of 20:06, 22 July 2010

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'
 Do
   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