emacs.d/clones/lisp/HyperSpec-7-0/HyperSpec/Body/f_format.htm
2023-01-18 20:30:47 +01:00

57 lines
6.4 KiB
HTML

<!-- Common Lisp HyperSpec (TM), version 7.0 generated by Kent M. Pitman on Mon, 11-Apr-2005 2:31am EDT -->
<HTML>
<HEAD>
<TITLE>CLHS: Function FORMAT</TITLE>
<LINK HREF="../Data/clhs.css" REL="stylesheet" TYPE="text/css" />
<META HTTP-EQUIV="Author" CONTENT="Kent M. Pitman">
<META HTTP-EQUIV="Organization" CONTENT="LispWorks Ltd.">
<LINK REL=TOP HREF="../Front/index.htm">
<LINK REL=COPYRIGHT HREF="../Front/Help.htm#Legal">
<LINK REL=DISCLAIMER HREF="../Front/Help.htm#Disclaimer">
<LINK REL=PREV HREF="f_pr_not.htm">
<LINK REL=UP HREF="c_printe.htm">
<LINK REL=NEXT HREF="23_.htm">
</HEAD>
<BODY>
<H1><A REV=MADE HREF="http://www.lispworks.com/"><IMG WIDTH=80 HEIGHT=65 ALT="[LISPWORKS]" SRC="../Graphics/LWSmall.gif" ALIGN=Bottom></A><A REL=TOP HREF="../Front/index.htm"><IMG WIDTH=237 HEIGHT=65 ALT="[Common Lisp HyperSpec (TM)]" SRC="../Graphics/CLHS_Sm.gif" ALIGN=Bottom></A> <A REL=PREV HREF="f_pr_not.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="c_printe.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="23_.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<A NAME="format"><I>Function</I> <B>FORMAT</B></A> <P>
<P><B>Syntax:</B><P>
<P>
<B>format</B> <I>destination control-string <TT>&amp;rest</TT> args</I> =&gt; <I>result</I><P>
<P>
<P><B>Arguments and Values:</B><P>
<P>
<I>destination</I>---<A REL=DEFINITION HREF="a_nil.htm#nil"><B>nil</B></A>, <A REL=DEFINITION HREF="a_t.htm#t"><B>t</B></A>, a <A REL=DEFINITION HREF="26_glo_s.htm#stream"><I>stream</I></A>, or a <A REL=DEFINITION HREF="26_glo_s.htm#string"><I>string</I></A> with a <A REL=DEFINITION HREF="26_glo_f.htm#fill_pointer"><I>fill pointer</I></A>. <P>
<I>control-string</I>---a <A REL=DEFINITION HREF="26_glo_f.htm#format_control"><I>format control</I></A>. <P>
<I>args</I>---<A REL=DEFINITION HREF="26_glo_f.htm#format_argument"><I>format arguments</I></A> for <I>control-string</I>. <P>
<I>result</I>---if <I>destination</I> is <A REL=DEFINITION HREF="26_glo_n.htm#non-nil"><I>non-nil</I></A>, then <A REL=DEFINITION HREF="a_nil.htm#nil"><B>nil</B></A>; otherwise, a <A REL=DEFINITION HREF="26_glo_s.htm#string"><I>string</I></A>. <P>
<P><B>Description:</B><P>
<P>
<A REL=DEFINITION HREF="#format"><B>format</B></A> produces formatted output by outputting the characters of <I>control-string</I> and observing that a <A REL=DEFINITION HREF="26_glo_t.htm#tilde"><I>tilde</I></A> introduces a directive. The character after the tilde, possibly preceded by prefix parameters and modifiers, specifies what kind of formatting is desired. Most directives use one or more elements of <I>args</I> to create their output. <P>
If <I>destination</I> is a <A REL=DEFINITION HREF="26_glo_s.htm#string"><I>string</I></A>, a <A REL=DEFINITION HREF="26_glo_s.htm#stream"><I>stream</I></A>, or <A REL=DEFINITION HREF="a_t.htm#t"><B>t</B></A>, then the <I>result</I> is <A REL=DEFINITION HREF="a_nil.htm#nil"><B>nil</B></A>. Otherwise, the <I>result</I> is a <A REL=DEFINITION HREF="26_glo_s.htm#string"><I>string</I></A> containing the `output.' <P>
<A REL=DEFINITION HREF="#format"><B>format</B></A> is useful for producing nicely formatted text, producing good-looking messages, and so on. <A REL=DEFINITION HREF="#format"><B>format</B></A> can generate and return a <A REL=DEFINITION HREF="26_glo_s.htm#string"><I>string</I></A> or output to <I>destination</I>. <P>
For details on how the <I>control-string</I> is interpreted, see <A REL=CHILD HREF="22_c.htm">Section 22.3 (Formatted Output)</A>. <P>
<P><B>Examples:</B> None.
<P>
<P><B>Affected By:</B><P>
<P>
<A REL=DEFINITION HREF="v_debug_.htm#STstandard-outputST"><B>*standard-output*</B></A>, <A REL=DEFINITION HREF="v_pr_esc.htm#STprint-escapeST"><B>*print-escape*</B></A>, <A REL=DEFINITION HREF="v_pr_bas.htm#STprint-radixST"><B>*print-radix*</B></A>, <A REL=DEFINITION HREF="v_pr_bas.htm#STprint-baseST"><B>*print-base*</B></A>, <A REL=DEFINITION HREF="v_pr_cir.htm#STprint-circleST"><B>*print-circle*</B></A>, <A REL=DEFINITION HREF="v_pr_pre.htm#STprint-prettyST"><B>*print-pretty*</B></A>, <A REL=DEFINITION HREF="v_pr_lev.htm#STprint-levelST"><B>*print-level*</B></A>, <A REL=DEFINITION HREF="v_pr_lev.htm#STprint-lengthST"><B>*print-length*</B></A>, <A REL=DEFINITION HREF="v_pr_cas.htm#STprint-caseST"><B>*print-case*</B></A>, <A REL=DEFINITION HREF="v_pr_gen.htm#STprint-gensymST"><B>*print-gensym*</B></A>, <A REL=DEFINITION HREF="v_pr_ar.htm#STprint-arrayST"><B>*print-array*</B></A>. <P>
<P><B>Exceptional Situations:</B><P>
<P>
If <I>destination</I> is a <A REL=DEFINITION HREF="26_glo_s.htm#string"><I>string</I></A> with a <A REL=DEFINITION HREF="26_glo_f.htm#fill_pointer"><I>fill pointer</I></A>, the consequences are undefined if destructive modifications are performed directly on the <A REL=DEFINITION HREF="26_glo_s.htm#string"><I>string</I></A> during the <A REL=DEFINITION HREF="26_glo_d.htm#dynamic_extent"><I>dynamic extent</I></A> of the call. <P>
<P><B>See Also:</B><P>
<P>
<A REL=DEFINITION HREF="f_wr_pr.htm#write"><B>write</B></A>, <A REL=CHILD HREF="13_aj.htm">Section 13.1.10 (Documentation of Implementation-Defined Scripts)</A> <P>
<P><B>Notes:</B> None.
<P>
<P><HR>The following <A REL=META HREF="../Front/X3J13Iss.htm">X3J13 cleanup issues</A>, <I>not part of the specification</I>, apply to this section:<P><UL><LI> <A REL=CHILD HREF="../Issues/iss330.htm">STRING-OUTPUT-STREAM-BASHING:UNDEFINED</A><LI> <A REL=CHILD HREF="../Issues/iss170.htm">FORMAT-STRING-ARGUMENTS:SPECIFY</A><P></UL><HR>
<A REL=NAVIGATOR HREF="../Front/StartPts.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Starting Points]" SRC="../Graphics/StartPts.gif" ALIGN=Bottom></A><A REL=TOC HREF="../Front/Contents.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Contents]" SRC="../Graphics/Contents.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Master.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Index]" SRC="../Graphics/Index.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Symbol.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Symbols]" SRC="../Graphics/Symbols.gif" ALIGN=Bottom></A><A REL=GLOSSARY HREF="../Body/26_a.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Glossary]" SRC="../Graphics/Glossary.gif" ALIGN=Bottom></A><A HREF="../Front/X3J13Iss.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Issues]" SRC="../Graphics/Issues.gif" ALIGN=Bottom></A><BR>
<A REL=COPYRIGHT HREF="../Front/Help.htm#Legal"><I>Copyright 1996-2005, LispWorks Ltd. All rights reserved.</I></A><P>
</BODY>
</HTML>