From: Friedrich Dominicus
Subject: A question  about format
Date: 
Message-ID: <87el6m653k.fsf@fbigm.here>
first the probably simler one. 
Is the a format directive which just prints x elements from a which
might be longer. The Minimum width is clear but how about the maximum
example
"string_with_19_chars"
(format t "??maxel11" ...) -> string_with

Regards
Friedrich

From: Geoffrey Summerhayes
Subject: Re: A question  about format
Date: 
Message-ID: <Oxd0a.2694$qQ.824826@news20.bellglobal.com>
"Friedrich Dominicus" <·····@q-software-solutions.com> wrote in message ···················@fbigm.here...
> first the probably simler one.
> Is the a format directive which just prints x elements from a which
> might be longer. The Minimum width is clear but how about the maximum
> example
> "string_with_19_chars"
> (format t "??maxel11" ...) -> string_with
>

*ducking for cover*

(defun a (stream arg &optional (colon-p nil) (at-sign nil)
                          (mincol 0) (maxcol 0) (colinc 1) (minpad 0)
                          (padchar #\Space))
  (let ((*print-readably* nil)
        (*print-escape* nil)
        (mod
         (format nil
                 (format nil ····@[~A~],·@[~A~],·@[~A~],·@['~A~]·@[:~]·@[@~]A"
                         mincol colinc minpad padchar colon-p at-sign) arg)))
      (if maxcol
          (write (subseq mod 0 (min maxcol (length mod))) :stream stream)
        (write mod :stream stream))))

: (format t "~20,20/A/" "jhgfjdhgjhdghdhgkjhdfkgjhdkjhgkjdh")
jhgfjdhgjhdghdhgkjhd
NIL

: (format t "~20,20,,,··@/A/" "jhg")
-----------------jhg
NIL

: (format t "~20,20,,,'-/A/" "jhg")
jhg-----------------
NIL

--
Geoff
From: Geoffrey Summerhayes
Subject: Re: A question  about format
Date: 
Message-ID: <pGd0a.2697$qQ.825964@news20.bellglobal.com>
"Geoffrey Summerhayes" <·············@hotmail.com> wrote in message ·························@news20.bellglobal.com...
>
> "Friedrich Dominicus" <·····@q-software-solutions.com> wrote in message ···················@fbigm.here...
> > first the probably simler one.
> > Is the a format directive which just prints x elements from a which
> > might be longer. The Minimum width is clear but how about the maximum
> > example
> > "string_with_19_chars"
> > (format t "??maxel11" ...) -> string_with
> >
>
> *ducking for cover*
>
> (defun a (stream arg &optional (colon-p nil) (at-sign nil)
>                                   (mincol 0) (maxcol 0) (colinc 1) (minpad 0)
                                               ^^^^^^^^^^
Damn! that should be                           (maxcol nil)

--
Geoff
From: sv0f
Subject: Re: A question  about format
Date: 
Message-ID: <none-0502031537490001@129.59.212.53>
In article <····················@news20.bellglobal.com>, "Geoffrey
Summerhayes" <·············@hotmail.com> wrote:

>*ducking for cover*

*readying thermonuclear device*
From: Barry Margolin
Subject: Re: A question  about format
Date: 
Message-ID: <6uc0a.10$hw1.686@paloalto-snr1.gtei.net>
In article <··············@fbigm.here>,
Friedrich Dominicus  <·····@q-software-solutions.com> wrote:
>first the probably simler one. 
>Is the a format directive which just prints x elements from a which
>might be longer. The Minimum width is clear but how about the maximum
>example
>"string_with_19_chars"
>(format t "??maxel11" ...) -> string_with

No.  The width specifications only specify a minimum width; if the data
doesn't fit, the field always expands to accomodate it.

If you want to do that, use SUBSEQ to extract the part of the string you
care about.

-- 
Barry Margolin, ······@genuity.com
Genuity Managed Services, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
From: Friedrich Dominicus
Subject: Re: A question  about format
Date: 
Message-ID: <878ywtlh63.fsf@fbigm.here>
Barry Margolin <······@genuity.net> writes:

> In article <··············@fbigm.here>,
> Friedrich Dominicus  <·····@q-software-solutions.com> wrote:
> >first the probably simler one. 
> >Is the a format directive which just prints x elements from a which
> >might be longer. The Minimum width is clear but how about the maximum
> >example
> >"string_with_19_chars"
> >(format t "??maxel11" ...) -> string_with
> 
> No.  The width specifications only specify a minimum width; if the data
> doesn't fit, the field always expands to accomodate it.
> 
> If you want to do that, use SUBSEQ to extract the part of the string you
> care about.
Ok, I suspected that but I was not sure if I have overread something
in the HyperSpec.

I guess I know how to cope with it.

Thanks
Friedrich
From: Wolfhard Buß
Subject: Re: A question  about format
Date: 
Message-ID: <m3znpapi5b.fsf@buss-14250.user.cis.dfn.de>
Friedrich Dominicus <·····@q-software-solutions.com> writes:
>
> "string_with_19_chars"
> (format t "??maxel11" ...) -> string_with

Maybe the well-known ~/foo/ format directive is what you are looking
for. An implementation might look like

 (defun foo (stream sequence colonp atp &optional (start 0) end)
   (declare (ignore colonp atp))
   (let ((start (or start 0)))
     (format stream "~A"  (subseq sequence start end))))

or similar.

 (format t "~,11/foo/" "string_with_19_chars")

prints `string_with'.

-- 
"Hurry if you still want to see something. Everything is vanishing."
                                       --  Paul C�zanne (1839-1906)