beautypg.com

Rpbasic-52 programming guide, On com – Remote Processing BASIC 52 User Manual

Page 85

background image

RPBASIC-52 PROGRAMMING GUIDE

2-66

ON COM$

Syntax:

O N C O M $port,length,terminator,program line
O N C O M $port
Where: port = the com port numbe r 0 or 1

length = numb er of received ch aracters for an interrupt
terminator = character to cause an interrupt
program line = executes subroutine when length or terminator is met.

Function:

Branches to a subroutine when length or terminator criteria is met.

Mode:

Run

Use:

ON CO M$0,5,13,1000

Executes su broutine at line 100 0 when eith er 5 characters or a is
received.

Cards:

RPC-320, RPC-330

D E S C R IP T I ON

ON CO M$ is a mu ltitaski ng stat eme nt. length and terminator parameters are checked on every received
character in the background. If either parameter is met, the program branches to the program line designated.

The first syntax en ables ON COM $ while the se cond one turns it off.

When terminator is 0, then character values are not checked. Only a length criteria will cause a n interrupt.

R e v ie w HARDWAR E AND SOFTWARE INTERRU PTS in the first part of this manual for interrupt
handling and multitasking information. A far more extensive example is shown earlier in this manual under
Serial Multitasking.

RELATED

C O M $

E R R O R

BAD A RGUM ENT when length or terminator > 255.

EXAMPLE

The follow ing exam ple executes a program a t line 1000 wh en either 5 chara cters or the cha racter is
received. The received string is transfe rred to $(0) minus th e character.

10 STRING 200,20
20 ON COM$0,5,13,1000
100 IDLE
200 GOTO 100
1000 $(0)=COM$(0)
1010 PRINT "COM string:",$(0)
1020 RETURN