From: Barry Margolin
Subject: Re: Passing variable as argument
Date: 
Message-ID: <4yWW3.5$KP4.350@burlma1-snr2>
In article <·················@direct.ca>,
Devin Currie  <········@direct.ca> wrote:
>;; The main function.
>(defun WriteSesFile (FileName)
>   (declare (string FileName))
>   "This is the main function to write the SES file. Default file
>location is e:\\Projects\\Ses\\."
>   (setf path (make-pathname :device "e" :directory "/projects/ses/"
>:name FileName :type "ses"))
>   (let (stream (open path :direction :output :if-exists :supersede))
>      (WriteSection 'WriteHeader stream)
>      (close stream))
>   (setf path nil))

You left out a set of parentheses in the LET bindings.  As a result, what
you wrote was equivalent to:

    (let ((stream nil)
          (open path :direction :output :if-exists :supersede))
      (writeSection 'WriteHeader stream)
      (close stream))

I'm surprised you didn't get a syntax error, due to the extra expressions
in the binding of OPEN.

-- 
Barry Margolin, ······@bbnplanet.com
GTE Internetworking, Powered by BBN, Burlington, 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: Stanley
Subject: Re: Passing variable as argument
Date: 
Message-ID: <383f58f4.14975393@192.168.200.30>
I'd use with-open-file instead of explicitly closing the stream.
Generally that gives better error handling (for example, if one of the
functions signals an error and control exits abnormally, the stream
should still be closed properly)


On Mon, 13 Dec 1999 13:04:36 -0700, Devin Currie <········@direct.ca>
wrote:

>Ah, I see now. So I am missing out one set of parenthesis for LET. I have rewrote my function
>as:
>
>;; The main function.
>(defun WriteSesFile (FileName)
>   (declare (string FileName))
>   "This is the main function to write the SES file. Default file location is e:\\Projects\\Ses\\."
>   (setf path (make-pathname :device "e" :directory "/projects/ses/" :name FileName :type "ses"))
>   (let ((stream (open path :direction :output :if-exists :supersede)))
>      (WriteSection 'WriteHeader stream)
>      (close stream))
>   (setf path nil))
>
>Thanks!
>
>Barry Margolin wrote:
>
>> In article <·················@direct.ca>,
>> Devin Currie  <········@direct.ca> wrote:
>> >;; The main function.
>> >(defun WriteSesFile (FileName)
>> >   (declare (string FileName))
>> >   "This is the main function to write the SES file. Default file
>> >location is e:\\Projects\\Ses\\."
>> >   (setf path (make-pathname :device "e" :directory "/projects/ses/"
>> >:name FileName :type "ses"))
>> >   (let (stream (open path :direction :output :if-exists :supersede))
>> >      (WriteSection 'WriteHeader stream)
>> >      (close stream))
>> >   (setf path nil))
>>
>> You left out a set of parentheses in the LET bindings.  As a result, what
>> you wrote was equivalent to:
>>
>>     (let ((stream nil)
>>           (open path :direction :output :if-exists :supersede))
>>       (writeSection 'WriteHeader stream)
>>       (close stream))
>>
>> I'm surprised you didn't get a syntax error, due to the extra expressions
>> in the binding of OPEN.
>>
>> --
>> Barry Margolin, ······@bbnplanet.com
>> GTE Internetworking, Powered by BBN, Burlington, 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.

----
 lxb
I prefer Latex and Bondage as ways of relaxing.
Do you have a problem with that?