get Statement

The get statement gets raw characters from the specified port.

Syntax

get var{,length} {setting character.count} from port.exp {until termination.characters} {returning termination.characters} {waiting seconds.exp} {then|else statement.block}

Parameter(s)

var

Receives the input. Printable characters are echoed to the line, unless the program issues an echo off statement. Control characters are included, but not echoed to the screen. No prompt displays.

length

Maximum characters to get. If no length is specified, and there is no until clause, 1 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.

character.count

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.

port.exp

Port from which to get characters. This port must have been previously attached with the TCL dev-att command. If an invalid port number is specified or the port is not attached, the else clause is taken.

termination.characters

Defines a set of characters that 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 that 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 time-out occurs, all input received up to this point is returned in the variable, and the else clause, if present, is executed.

 

NOTE

When using an expression in the until clause, it is necessary to enclose that expression in parentheses for proper recognition.

Data read by the get statement is normally echoed, unless the program issues an echo off statement.

Example(s)

This obtains 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, the statement terminates. Note that xx contains a maximum of 5 characters. The term variable contains the character that actually terminated input.

execute \unlink-pibdev 10,10\

execute \dev-att 10\

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

execute \dev-det 10\

execute \link-pibdev 10,10\

See Also

dev-att Command

dev-det Command

echo Statement

in Statement

input Statement

send Statement

setting Clause

Statement Blocks

Statements and Functions

then/else Statement Blocks

ud0ba User Exit