$CARRIER is the status of the CD (carrier detect)
of RS-232.
1 = CD HIGH, carrier present
0 = CD LOW, carrier absent
$CARRIER works only in TERMINAL or TELNET modes.
In your sample, try:
if $CARRIER 1
call routine
else
endif
"I will not be pushed, filed, stamped, indexed, briefed...