Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Telix/SALT v3.15 & RS-232, Hayes - <b>track_addchr</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
  TRACK_ADDCHR

  .  Summary

  track_addchr(int <chr>);

  .  Description

  The track_addchr is used to add a character which the script has
  removed from the input buffer to the queue that is processed by
  terminal().  This is necessary whenever tracks are active and
  the script uses cgetc() or cgetct()

  The track and related functions are used to keep track of and wait
  for certain strings to come in over the comm port, similar in nature
  to the waitfor function. However the latter function can only wait
  for one specific string, while with the track functions can handle
  more strings at the same time (currently up to 16), and they may ar-
  rive in any order (or not arrive at all).

  When track is called, Telix doesn't loop endlessly waiting for the
  string to come in, but instead returns back to the script. As char-
  acters come in, Telix checks to see if any of the strings to be
  tracked have been matched, and marks those that have. A script can
  at any time call the track_hit function to see if the string repre-
  sented by <handle> was received. If track_hit returns a non-zero
  (TRUE) value, then that string was received, otherwise it wasn't. If
  <handle> is 0, then track_hit will return the lowest numbered handle
  of any strings that came in, or 0 if none did. The marker on a han-
  dle is cleared once track_hit has indicated that the appropriate
  string was received.

  While a script is executing, Telix is not in terminal mode, and
  therefore does not have access to incoming characters, to scan for
  matching strings. Therefore, the terminal function must periodically
  be called to allow Telix to get a look at incoming characters. This
  function is described in the appropriate place in this manual. Al-
  ternately, if a script must process these characters itself (with a
  function like cgetc), and therefore can not call the terminal func-
  tion, they must still be passed by the track routines for string
  matching to work. The track_addchr function is used for this. When
  it is called, Telix treats the character represented by <chr> as if
  it had been received from the terminal handler, and uses it to scan
  for matching strings.

  .  Return Value

  none

  .  Example
                        // Track the desired string
   string_track = track (search_string, case_sensitive);
                        // Start a timer
   timer = timer_start (time_out*10);

   while (not time_up (timer)){
                        // If there are any characters waiting
      if (cinp_cnt()) {
                        // Get character, print it, tell the
                        // tracking function about it
         track_addchr (printc (cgetc ()));
                        // See if desired string has shown up
         if (track_hit (string_track)) {
            break;
         }
      }
   }

See Also: waitfor track track_free track_hit cgetc cgetct ASCII table

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson