11.07.2015 Views

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

READtimeoutThe number of seconds to wait for the request to succeed. This argument is optional, but ifspecified, the preceding colon is required. You must specify timeout as an integer or anexpression that evaluates to an integer. The timeout argument sets the $TEST special variableas follows:• READ with timeout argument completes successfully (does not time out): $TEST setto 1.• READ with timeout argument times out: $TEST set to 0.• READ with no timeout argument: $TEST remains set to its previous value.If the timeout period expires before the READ completes and some characters have beeninput (for a variable-length or fixed-length reads) the input characters are stored in variable.If no characters have been input (for a variable-length or fixed-length reads), <strong>Caché</strong> definesvariable (if necessary) and sets it to the null string. If no character has been input for a singlecharacterREAD, <strong>Caché</strong> defines variable (if necessary) and sets it to –1.ExamplesThe following example uses the variable-length form of READ to acquire any number ofcharacters from the user. The format control ! starts the prompt on a new line.READ !,"Enter your last name: ",lnameThe following example uses the single-character form of READ to acquire one characterfrom the user and store it as its ASCII decimal equivalent.READ !,"Enter option number (1,2,3,4): ",*optWRITE !,"ASCII value input=",optWRITE !,"Character input=",$KEYThe following example uses the fixed-length form of READ to acquire exactly three charactersfrom the user.READ !,"Enter your 3-digit area code: ",area#3The following example prompts for three parts of a name: a fixed-length given name (gname)of up to 12 characters, a fixed-length (one-character) middle initial (iname), and a familyname (fname) of any length. The gname and iname variables are coded to time out after 10seconds:READ "Given name:",gname#12:10,!,"Middle initial:",iname#1:10,!,"Family name:",fnameWRITE $TEST<strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong> 119

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!