READ Command

Material prepared from M Programming Book (Page 84) [WALTERS1997] and GT.M Programmer’s Guide

Description

R[EAD]

R[EAD]: (variable|*variable|variable#size)[:timeout] [string literal]

Arguments:

Must be one of the following:

  • string literal
  • format command
  • variable[#count][:timeout]
  • *variable[:timeout]

If the argument is a string literal or format command, the READ command cancels any pending read-ahead then functions as a WRITE command.

If #count is present, #count is the maximum number of characters that will be read into the variable. However it does not restrict the number of characters that may be read into the $KEY variable.

The timeout is specified in seconds. If :timeout is specified; $TEST is set to 0 and $KEY is set to null if the read terminated because of expiration fo specified time. If time did not run out it is set to 1 otherwise. The variable will contain all the characters received prior to the timeout.

Examples

READ "What is your name ?",!,YOURNAME
READ !,"Answer: ",ANS:10 ;Give them 10 seconds to answer