bas7advr.hlp (Topic list)
ON COM Statement Details
  Syntax  Details  Example                 Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
ON COM specifies a routine to branch to when characters are received at
communications port n%.
 
ON COM(n%) GOSUB {linenumber | linelabel}
    ■ linenumber or    A linenumber value of 0 disables event trapping and
      linelabel        does not specify line 0 as the start of the
                       routine.
 
Usage Notes
    ■ If your program receives data using an asynchronous communications
      adapter, the BASIC command-line option /C can be used to set the
      size of the data buffer.
    ■ The ON COM statement specifies only the start of an event-trapping
      routine. The COM Statements determine whether the routine is
      called and how events are handled when trapping is off:
 
        COM ON      Enables event trapping. Event trapping occurs only
                    after a COM ON statement is executed.
        COM OFF     Disables event trapping. Even if an event takes place,
                    it is not remembered.
        COM STOP    Suspends event trapping. Any events that occur are
                    remembered and are trapped as soon as a COM ON statement
                    is executed.
 
    ■ If your program contains event-handling statements and you are
      compiling from the BC command line, use the BC /W or /V option.
      (The /W option checks for events at every label or line number; the
      /V option checks at every statement.) If you do not use these
      options and your program contains event traps, BASIC generates the
      error message, "ON event without /V or /W on command line."
    ■ The RETURN linenumber or RETURN linelabel forms of RETURN can be
      used to return to a specific line from the trapping routine. Use
      this type of return with care, however, because any other GOSUB,
      WHILE, or FOR statements active at the time of the trap remain
      active. BASIC may generate error messages such as "NEXT without
      FOR." In addition, if an event occurs in a procedure, a RETURN
      linenumber or RETURN linelabel statement cannot get back into the
      procedure because the line number or label must be in the
      module-level code.