basic.get

Statement/BASIC Program, Releases:

Gets raw characters from another port.

Syntax

get{x} variable{,length} {setting character.count} from port.expression {until termination.character(s)} {returning termination.character(s)} {waiting seconds.expression} {then|else statement.block}

Description

gets raw characters from the specified port.
'variable' receives the input. Printable characters are echoed to the line, unless the program issues a 'ECHO OFF' statement. Control characters are included, but not echoed to the screen. No prompt is displayed.
'length' is the maximum characters to get. If no length is specified, and there is no 'until' clause, '1' (one) is the default. If the length is specified, but this number of characters is not entered, the system waits indefinitely or until the 'waiting' clause times out, the 'termination.character' is entered, or the 'length' is satisfied. If the 'length' is satisfied, the 'then' clause is executed.
'setting' specifies the number of characters to be returned. If the 'length' expression is less than the number of characters specified by 'setting', input terminates at the length. If the 'length' expression is greater than 'setting', only the number of characters specified by the 'setting' are returned to the variable.
'from' is the port from which to get characters. This port must have been previously attached with the 'dev-att' command. If an invalid port number is specified or the port is not attached , then the 'else' clause is taken.
'until' defines a set of characters which terminate input. If the 'x' option is not in effect, the input also terminates on a char(255) (x'ff'). The 'termination.character' is not included in the returned string. When a 'termination.character' is received, the 'then' clause is executed.
'returning' returns the character which terminated input. If the 'returning' variable is null, and either no length is specified, or the returned data length is less than the length limit, a segment mark (x'ff') is assumed as the 'termination.character'.
'waiting' specifies how long, in tenths of a second, the system should wait until an input termination condition exists (such as satisfying the length requirement or the 'until' clause). If a timeout occurs, all input received up to this point is returned in the 'variable', and the 'else' clause, if present, is executed.
'getx' returns an exploded ASCII hexadecimal string which allows binary data to contain a decimal 255 (x'ff').

Example

get xx,80 setting 5 from 10 until (char(13):char(10)) returning term waiting 60

This will get up to 80 characters from port 10 until that port generates a
carriage return (char(13)) or linefeed (char(10)). If more than 6 seconds
elapse, then the statement terminates. Note that xx will contain a maximum of
5 characters. The 'term' variable will contain which character
actually terminated input.

getx xx,10 from 10 waiting 50

If 'HELLO' is entered on port 10, xx will contain
'48454C4C4F'. If the string, 'HE<backspace>LLO' is
entered, xx will contain '4845084C4C4F', where the '08' is
the backspace character.

See Also

Command Name Type Description
basic.send Statement Sends output to a specific port.
tcl.dev-att Verb: Access Attaches a port to the current port.
basic.input@ Statement Stops program to accept input.
returning Command see 'execute' and 'get'.
basic.in Statement Inputs single character.
tcl.dev-det Verb: Access Detaches a port from the current port.
waiting Command see 'get'.
statement.block Definition one or more statements that follow a Pick/BASIC decision-path related token such as, but not limited to, 'then', 'else', 'locked' and 'onerr'.
basic.statements Definition Definition of statements and functions.
basic.then/else.construct Definition provide program flow change based upon a boolean condition.
ue.d0ba User Exit Reads a character byte from a serial port.
setting Command see 'get' and 'locate'.
basic.echo Statement Toggles terminal echo.

User Comments

What do you think?

Share your experience or ask a question by using the form below.

Login to leave your comments.