General EQWatcher Concepts > Venturing into the Unknown  > Timers


List of commands

AddTimer(string name, unsigned long length, soundtype, string soundinfo)

RemoveTimer(string name)


AddTimer(string name, unsigned long length, soundtype, string soundinfo) Command

Adds a timer with specified information.

Return value

boolean value true if successful, false if not

Parameters

name

The name can be basically any name, this will be used to identify this specific Timer.  This name should be unique to this Timer.

length

The length of time before the timer detonates, given in milliseconds.

soundtype

The soundtype parameter is not given a data type because it CANNOT be a value other than the constants defined for this purpose.  SND_WAVE, SND_CD, SND_TTS, SND_MP3, SND_ALIAS, SND_SYNCWAVE, SND_SYNCTTS.  This must be hard-coded and may not use a variable value.

soundinfo

The soundinfo parameter goes along with the sound type.  For SND_WAVE and SND_SYNCWAVE you must supply a filename.  For SND_TTS and SND_SYNCTTS you must supply text to speak.  For SND_CD you must supply a track number to play.  For SND_MP3 you must supply a search string.  For SND_ALIAS you must supply the command to execute (variables using %% and @@ WILL be processed).

Example

// This alias adds a SND_WAVE timer

public string TimerName;
public unsigned long TimerMins;
public unsigned long TimerSecs;
public string TimerSound;

alias("timer wav \"@TimerName@\" @TimerMins@:@TimerSecs@ \"@TimerSound@\"");
{
  unsigned long TimerMS; // Milliseconds of timer length

  // Conversion to minutes:seconds to seconds
  // (Minutes*(60 seconds/1 minute) + Seconds)

  // Conversion of seconds to milliseconds
  // Seconds*(1000 milliseconds/1 second)

  // Apply formula:
  TimerMS=(TimerMins*60+TimerSecs)*1000;

  if (AddTimer(TimerName,TimerMS,SND_WAVE,TimerSound)==true)
  {
  SpeakSync("Timer added");
  }
  else
  {
  SpeakSync("Timer not added");
  }
}
 


RemoveTimer(string name) command

Removes timer with the specified name

Return value

boolean value true if successful, false if not

Parameters

name

Name of the timer to remove.

Example

// This alias removes a Timer given the name

public string TimerName;
alias("timer remove \"@TimerName@\"")
{
  if (RemoveTimer(TimerName))
  {
    SpeakSync("Timer removed");
  }
  else
  {
    SpeakSync("Timer did not exist");
  }
}