Prev: Simple Hack To Get $2000 To Your PayPal Account
Next: NYC LOCAL: Tuesday 13 July 2010 Lisp NYC: Eating, Drinking, Talking
From: Francogrex on 13 Jul 2010 16:40 On Jul 13, 6:25 pm, Barry Fishman <barry_fish...(a)acm.org> wrote: > If you want tabs in the output you need to put them directly > in the format spec, or indirectly by some means like: > > (let ((fspec (format nil "~~{~~s~c~~}" #\tab))) > (with-open-file (stream "c:/tabout.txt" :direction :output) > (format stream fspec (list 1 2 3 4 5))) This works fine. Thanks
From: Rob Warnock on 13 Jul 2010 19:29 Francogrex <franco(a)grex.org> wrote: +--------------- | Barry Fishman <barry_fish...(a)acm.org> wrote: | > If you want tabs in the output you need to put them directly | > in the format spec, or indirectly by some means like: | > | > (let ((fspec (format nil "~~{~~s~c~~}" #\tab))) | > (with-open-file (stream "c:/tabout.txt" :direction :output) | > (format stream fspec (list 1 2 3 4 5))) | | This works fine. Thanks +--------------- Though that will leave a "tangling" tab at the end of each line, and provide no newline at the ends. You might prefer this FSPEC: (let ((fspec (format nil "~~{~~s~~^~c~~}~~%" #\tab))) (with-open-file (stream "c:/tabout.txt" :direction :output) (format stream fspec (list 1 2 3 4 5)))) -Rob ----- Rob Warnock <rpw3(a)rpw3.org> 627 26th Avenue <URL:http://rpw3.org/> San Mateo, CA 94403 (650)572-2607
From: Barry Fishman on 13 Jul 2010 21:45 pjb(a)informatimago.com (Pascal J. Bourguignon) writes: > All right, but to make it a portable program, you would have to do this: > > (when (ignore-errors (read-from-string "#\\tab")) > (push :has-tab *features*)) > > (let ((fspec #+has-tab (format nil "~~{~~s~c~~}" #\tab) > #-has-tab "~11S ")) > (with-open-file (stream "c:/tabout.txt" :direction :output) > (format stream fspec (list 1 2 3 4 5)))) Do portable programs accept file names in the form "c:/tabout.txt"? -- Barry Fishman
From: Pascal J. Bourguignon on 14 Jul 2010 00:48
Barry Fishman <barry_fishman(a)acm.org> writes: > pjb(a)informatimago.com (Pascal J. Bourguignon) writes: >> All right, but to make it a portable program, you would have to do this: >> >> (when (ignore-errors (read-from-string "#\\tab")) >> (push :has-tab *features*)) >> >> (let ((fspec #+has-tab (format nil "~~{~~s~c~~}" #\tab) >> #-has-tab "~11S ")) >> (with-open-file (stream "c:/tabout.txt" :direction :output) >> (format stream fspec (list 1 2 3 4 5)))) > > Do portable programs accept file names in the form "c:/tabout.txt"? This is irrelevant. You may substitute *my-file-pathname* instead. -- __Pascal Bourguignon__ http://www.informatimago.com/ |