From: Nonzero
Subject: Write to file question...
Date: 
Message-ID: <376b0355.0303080946.71dedddf@posting.google.com>
Write to file question...

I would like to be able to write data to files with numbers after them like so:

datafile1.txt
datafile2.txt
datafile3.txt

and so on.

What I have right now is this

    (with-open-file (out "datafile.txt"
                         :direction :output :if-exists :append
                         :if-does-not-exist :create)

Which will give me a datafile.txt without a number.

How do I append my variable 'number' to the datafile?

Thank you in advance for your assistance.

-Colin

From: Geoffrey Summerhayes
Subject: Re: Write to file question...
Date: 
Message-ID: <Ngqaa.10172$Or5.1197265@news20.bellglobal.com>
"Nonzero" <····@geneseo.edu> wrote in message ·································@posting.google.com...
> Write to file question...
>
> I would like to be able to write data to files with numbers after them like so:
>
> datafile1.txt
> datafile2.txt
> datafile3.txt
>
> and so on.
>
> What I have right now is this
>
>     (with-open-file (out "datafile.txt"
>                          :direction :output :if-exists :append
>                          :if-does-not-exist :create)
>
> Which will give me a datafile.txt without a number.
>
> How do I append my variable 'number' to the datafile?

(with-open-file
  (out (format nil "datafile~A.txt" number)
    :direction :output :if-exists :append
    :if-does-not-exist :create)

--
Geoff
From: Marc Spitzer
Subject: Re: Write to file question...
Date: 
Message-ID: <86k7f98yrg.fsf@bogomips.optonline.net>
····@geneseo.edu (Nonzero) writes:

> Write to file question...
> 
> I would like to be able to write data to files with numbers after them like so:
> 
> datafile1.txt
> datafile2.txt
> datafile3.txt
> 
> and so on.
> 
> What I have right now is this
> 
>     (with-open-file (out "datafile.txt"
>                          :direction :output :if-exists :append
>                          :if-does-not-exist :create)
> 
> Which will give me a datafile.txt without a number.
> 
> How do I append my variable 'number' to the datafile?

* (setf gg (format nil "bob~d.txt" 14) )
Warning:  Declaring GG special.
bob14.txt
NIL
* gg

"bob14.txt"

should get you started, you may want to wrap the
whole thing in a let form though

marc



> 
> Thank you in advance for your assistance.
> 
> -Colin
From: Kenny Tilton
Subject: Re: Write to file question...
Date: 
Message-ID: <3E6A468A.4000104@nyc.rr.com>
Nonzero wrote:
>     (with-open-file (out "datafile.txt"
>                          :direction :output :if-exists :append
>                          :if-does-not-exist :create)
> 
> Which will give me a datafile.txt without a number.
> 
> How do I append my variable 'number' to the datafile?

others showed you how to use format to build your filename, but since 
you asked about appending...

(concatenate 'string "hello, " "world.")
=> "hello, world."

-- 

  kenny tilton
  clinisys, inc
  http://www.tilton-technology.com/
  ---------------------------------------------------------------
"Cells let us walk, talk, think, make love and realize
  the bath water is cold." -- Lorraine Lee Cudmore