User Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

cl:functions:write-string [2019/09/14 05:00]
cl:functions:write-string [2019/09/22 06:00] (current)
Line 1: Line 1:
 +====== Function WRITE-STRING,​ WRITE-LINE ======
 +
 +====Syntax====
 +  * **write-string** //string// ''&​optional''​ //​output-stream//​ ''&​key''​ //start// //end// → //​string// ​
 +  * **write-line** //string// ''&​optional''​ //​output-stream//​ ''&​key''​ //start// //end// → //string//
 +
 +====Arguments and Values====
 +  * //string// - a //​[[CL:​Glossary:​string]]//​.
 +  * //​output-stream//​ -- an //​[[CL:​Glossary:​output]]//​ //​[[CL:​Glossary:​stream designator]]//​. The default is //​[[CL:​Glossary:​standard output]]//.
 +  * //start//, //end// - //​[[CL:​Glossary:​bounding index designator|bounding index designators]]//​ of //string//. The defaults for //start// and //end// are ''​0''​ and **[[CL:​Constant Variables:​nil]]**,​ respectively.
 +
 +====Description====
 +**write-string** writes the //​[[CL:​Glossary:​character|characters]]//​ of the subsequence of //string// //​[[CL:​Glossary:​bounded]]//​ by //start// and //end// to //​output-stream//​. **write-line** does the same thing, but then outputs a newline afterwards.
 +
 +====Examples====
 +<​blockquote>​
 +([[CL:​Special Operators:​prog1]] ​
 +  (write-string "​books"​ [[CL:​Constant Variables:​nil]] :end 4) 
 +  (write-string "​worms"​))
 +<​o>​bookworms </o>
 +<​r>"​books"​ </r>
 +(progn ​
 +  ([[CL:​Functions:​write-char]] #\*) 
 +  (write-line "​test12"​ [[CL:​Variables:​star-standard-output-star|*standard-output*]] :end 5) 
 +  (write-line "​*test2"​) ​
 +  ([[CL:​Functions:​write-char]] #\*) 
 +  nil)
 +<​o>​*test1
 +*test2
 +* </o>
 +<​r>​NIL </r>
 +</​blockquote>​
 +
 +====Side Effects====
 +None.
 +
 +====Affected By====
 +**[[CL:​Variables:​star-standard-output-star|*standard-output*]]**,​ **[[CL:​Variables:​star-terminal-io-star|*terminal-io*]]**.
 +
 +====Exceptional Situations====
 +None.
 +
 +====See Also====
 +  * **[[CL:​Functions:​read-line|Function READ-LINE]]**
 +  * **[[CL:​Functions:​write-char|Function WRITE-CHAR]]**
 +
 +====Notes====
 +**[[CL:​Functions:​write-line]]** and **[[CL:​Functions:​write-string]]** return //string//, not the substring //​[[CL:​Glossary:​bounded]]//​ by //start// and //end//.
 +
 +<​blockquote> ​
 +(write-string string) ​
 +  ≡ ([[CL:​Macros:​dotimes]] (i ([[CL:​Functions:​length]] string)) ​
 +      ([[CL:​Functions:​write-char]] ([[CL:​Functions:​char]] string i)))
 +(write-line string) ​
 +  ≡ ([[CL:​Special Operators:​prog1]] ​
 +      (write-string string) ​
 +      ([[CL:​Functions:​terpri]])) </​blockquote>​
 +
 +\issue{SUBSEQ-OUT-OF-BOUNDS} \issue{RANGE-OF-START-AND-END-PARAMETERS:​INTEGER-AND-INTEGER-NIL} \issue{READ-AND-WRITE-BYTES:​NEW-FUNCTIONS}