From: verec
Subject: "tabular" format directives?
Date: 
Message-ID: <46d8d39f$0$639$5a6aecb4@news.aaisp.net.uk>
PCL (chapter 18) stops short of mentionning the format
directives aimed at outputting tables.

So, in order to get this:

CL-USER> (dump-a-few (merge-pathnames "/Users/verec/temp/test.bin"))

00000000: CAFEBABE 00000002 00000012 00000000
00000010: 00001000 00088CFC 0000000C 00000007
00000020: 00000003 0008A000 00091AF0 0000000C
00000030: 00000000 00000000 00000000 00000000
00000040: 00000000 00000000 00000000 00000000
00000050: 00000000 00000000 00000000 00000000
00000060: 00000000 00000000 00000000 00000000
00000070: 00000000 00000000 00000000 00000000
00000080: 00000000 00000000 00000000 00000000
00000090: 00000000 00000000 00000000 00000000
000000A0: 00000000 00000000 00000000 00000000
000000B0: 00000000 00000000 00000000 00000000
000000C0: 00000000 00000000 00000000 00000000
000000D0: 00000000 00000000 00000000 00000000
000000E0: 00000000 00000000 00000000 00000000
000000F0: 00000000 00000000 00000000 00000000
nil

CL-USER>

I wrote this:

(defun dump-a-few (file-name)
  (with-open-file (stream file-name
                          :direction :input
                          :element-type '(unsigned-byte 8))
    (let ((length (min 256 (file-length stream))))
      (loop for i from 0 below length do
            (when (eql 0 (rem i 16))
              (format t "~%~8,'0x: " i))
            (format t "~2,'0x" (read-byte stream))
            (when (eql 3 (rem i 4))
              (format t " "))))))

But that's a bit clumsy when I sense that the appropriate
set of format directives could handle all/most of it
without the need of an explicit loop.

Any pointer to some tutorial/example that would lead me the
right way?

Many thanks.
--
JFB

From: Rob Warnock
Subject: Re: "tabular" format directives?
Date: 
Message-ID: <jeudnSmrCvUEokTbnZ2dnUVZ_tXinZ2d@speakeasy.net>
verec  <·····@mac.com> wrote:
+---------------
| PCL (chapter 18) stops short of mentionning the format
| directives aimed at outputting tables.
...
| But that's a bit clumsy when I sense that the appropriate
| set of format directives could handle all/most of it
| without the need of an explicit loop.
| 
| Any pointer to some tutorial/example that would lead me the right way?
+---------------

Not sure, but take a look and see if the article I posted last week
<····································@speakeasy.net> helps at all...


-Rob

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: Cesar Rabak
Subject: Re: "tabular" format directives?
Date: 
Message-ID: <46D9D66E.7040904@yahoo.com.br>
Rob Warnock escreveu:
> verec  <·····@mac.com> wrote:
> +---------------
> | PCL (chapter 18) stops short of mentionning the format
> | directives aimed at outputting tables.
> ...
> | But that's a bit clumsy when I sense that the appropriate
> | set of format directives could handle all/most of it
> | without the need of an explicit loop.
> | 
> | Any pointer to some tutorial/example that would lead me the right way?
> +---------------
> 
> Not sure, but take a look and see if the article I posted last week
> <····································@speakeasy.net> helps at all...
> 
> 
Rob,

How do one person makes use of the link above to search the message?
From: verec
Subject: Re: "tabular" format directives?
Date: 
Message-ID: <46d9dc73$0$646$5a6aecb4@news.aaisp.net.uk>
On 2007-09-01 22:15:26 +0100, Cesar Rabak <·······@yahoo.com.br> said:

> Rob Warnock escreveu:
>> verec  <·····@mac.com> wrote:
>> +---------------
>> | PCL (chapter 18) stops short of mentionning the format
>> | directives aimed at outputting tables.
>> ...
>> | But that's a bit clumsy when I sense that the appropriate
>> | set of format directives could handle all/most of it
>> | without the need of an explicit loop.
>> | | Any pointer to some tutorial/example that would lead me the right way?
>> +---------------
>> 
>> Not sure, but take a look and see if the article I posted last week
>> <····································@speakeasy.net> helps at all...
> Rob,
> 
> How do one person makes use of the link above to search the message?

I can't answer that precise question either, but I guess that Rob
was referring to his reply to the "Newbie riddle" thread of Aug 24:

> | I like Juho's answer because it's the first time in my
> | (admittedly short) time lisping I've ever seen ~/ used.
> +---------------
> 
> Here's my only use of it [and also my only use of escape characters
> for symbol names!]... but I use it a *LOT* in my user-mode hardware
> debugger code [which also uses a ZERO-X-READER readmacro in its REPL]:
> 
>   (defun \0x (stream arg colon-p at-sign-p &optional mincol padchar)
>     "Hexadecimal numeric printing for use with the FORMAT ~/.../ directive.
>     Outputs ARG to STREAM as \"~(0x~mincol,padX~)\" [default \"~(0x~8,'0X~)\"].
>     If COLON-P, the entire output will be capitalized instead of lowercased.
>     If AT-SIGN-P is true, the \"0x\" prefix will be suppressed."
>     (let* ((fmt1 "~~~:[···@~](~:[0x~;~]~~~:[8~;~:*~a~],'~:[0~;~:*~a~]x~~)")
> 	   (fmt2 (format nil fmt1 colon-p at-sign-p mincol padchar)))
>       (format stream fmt2 arg)))
> 
> Examples:
> 
>     > (format t "~/0x/ == ~4/0x/ == ~2/0x/~%" #1=27 #1# #1#)
>     0x0000001b == 0x001b == 0x1b
>     NIL
>     > (format t ···@/0x/ == ···@/0x/ == ···@/0x/~%" #1=27 #1# #1#)
>     0000001B == 001B == 1B
>     NIL
>     > (format t "~/0x/~%" (+ 0x1234000 27))  ; demo the readmacro
>     0x0123401b
>     NIL
>     >
> 
> I also use it a lot when building data initialization tables in C code:
> 
>     > (let ((data (loop for i below 24 nconc (list (random 0x100000000)
> 						   (random 256))))
> 	    (instance "georgey"))
>         (format t "~%foo_t ~a_foos[~d] = {~
>               ~%~{~<~%~1,68:;  {~/0x/, ~2/0x/}~>~^,~}~%};~%"
>               instance (/ (length data) 2) data))
> 
>     foo_t georgey_foos[24] = {
>       {0x21a41a5c, 0x87},  {0x1c63b86e, 0xb4},  {0x894c25d5, 0xa1},
>       {0x9979b7fe, 0xbb},  {0xc2ad44aa, 0x4d},  {0xe2826239, 0x70},
>       {0x053b537e, 0x05},  {0x6ac226e8, 0xbe},  {0x1252ea73, 0x20},
>       {0xe3001d4a, 0x12},  {0x9a006313, 0x31},  {0x299d2f64, 0x54},
>       {0x90feb745, 0xda},  {0xc7ed257b, 0xc1},  {0xa6e8e18a, 0x51},
>       {0x0fdb8569, 0xed},  {0x713c27e0, 0xa8},  {0xd975dbac, 0x2d},
>       {0xb4263772, 0x85},  {0xe6cdaaa9, 0x48},  {0x7db24d29, 0xf8},
>       {0x87e5aa36, 0xa3},  {0xb56e3dd7, 0xe2},  {0x3cf23443, 0x4e}
>     };
>     NIL
>     >
> 
> [Note how the FORMAT string carefully leaves off the comma after the
> final element (even though this is no longer required in ANSI C).]
From: Rob Warnock
Subject: Re: "tabular" format directives?
Date: 
Message-ID: <rsadnbhD4L3xkUfbnZ2dnUVZ_u-unZ2d@speakeasy.net>
verec  <·····@mac.com> wrote:
+---------------
| Cesar Rabak <·······@yahoo.com.br> said:
| > Rob Warnock escreveu:
| >> Not sure, but take a look and see if the article I posted last week
| >> <····································@speakeasy.net> helps at all...
| > 
| > How do one person makes use of the link above to search the message?
| 
| I can't answer that precise question either, but I guess that Rob
| was referring to his reply to the "Newbie riddle" thread of Aug 24:
+---------------

Exactly. And my apologies to all, because it seems that I typo'd
[mouse-o'd?] the cut&paste of that Message-ID [left off an initial
letter "o"]. It *should* be this instead:

    <·····································@speakeasy.net>

And as far as the metaquestion about the URL itself, the
<news:message-id> notation is the RFC 1738 standard specification
for a netnews URL when denoting a single article by Message-ID.
[One may also write <news:newsgroup-name> to mean a whole group.
The two are disambiguated by the mandatory presence of an ·@"
in the former.]

If you have a news reader/server that can fetch an article directly
by Message-ID, simply do whatever command that is and give it the
·································@speakeasy.net" string as an argument.
[Some readers are smart enough to let you just click on the link above.]
If not, go to <http://groups.google.com/advanced_search> and enter
that string into the "Lookup the message with message ID" field and
click the "Lookup Message" button. [Note: If there's source code
involved (as there was in this case) you might want to further click
on "Show Original", to get a monospaced font.]


-Rob

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607