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.

WRITENote:An integer expression does not change the $X special variable when writing to aterminal. Thus, WRITE "a" and WRITE $CHAR(97) both increment the columnnumber value contained in $X, but WRITE *97 does not increment $X. For furtherdetails, see the $X special variable, and “Terminal I/O” in <strong>Caché</strong> I/O Device Guide.ExamplesIn the following example, the WRITE command sends the current value in variable var1 tothe current output device.SET var1="hello world"WRITE var1In the following example, both WRITE commands display the Unicode character for pi. Thefirst uses an expression, the second an integer-expression:WRITE !,$CHAR(960)WRITE !,*960The following example writes first name and last name values along with an identifying textfor each. The WRITE command combines multiple arguments on the same line. It is equivalentto the two WRITE commands in the example that follows it. The ! character is a formatcontrol that produces a line break. (Note that the ! line break character is still needed whenthe text is output by two different WRITE commands.)SET fname="Bertie"SET lname="Wooster"WRITE "First name: ",fname,!,"Last name: ",lnameis equivalent to:SET fname="Bertie"SET lname="Wooster"WRITE "First name: ",fname,!WRITE "Last name: ",lnameIn the following example, assume that the current device is the user's terminal. The READcommand prompts the user for first name and last name and stores the input values in variablesfname and lname, respectively. The WRITE command displays the values in fname andlname for the user's confirmation. The string containing a space character (" ") is included toseparate the output names.TestREAD !,"First name: ",fnameREAD !,"Last name: ",lnameWRITE !,fname," ",lnameREAD !,"Is this correct? (Y or N) ",check#1IF "Nn"[check {GOTO Test}<strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong> 163

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

Saved successfully!

Ooh no, something went wrong!