From: Nonzero
Subject: Some Progress!
Date: 
Message-ID: <5d8568f8.0111021802.3a4fad64@posting.google.com>
Hello all,
thanks for the help

I have finally made some progress. By using
(setq data-file (open "array-data.dat" :direction output
                                       :if-exists :overwrite
                                       :if-does-not-exist :create))

(let ((*print-array* t))
     (print my-array data-file))

This allows me to write my array to a file.

Whewph!

But now the question is how do I get it back?

Is there something like a *read-array* command, and if so, what do I
need to type.  I can't seem to find it anywhere.


Thanks again all
-Nonzero314

From: Pierre R. Mai
Subject: Re: Some Progress!
Date: 
Message-ID: <87zo645tgv.fsf@orion.bln.pmsf.de>
··········@hotmail.com (Nonzero) writes:

> I have finally made some progress. By using
> (setq data-file (open "array-data.dat" :direction output
>                                        :if-exists :overwrite
>                                        :if-does-not-exist :create))
> 
> (let ((*print-array* t))
>      (print my-array data-file))

What you really want is:

(defun save-my-data (array filename)
  (with-open-file (stream filename :direction :output)
    (with-standard-io-syntax
      ;; If you've got shared structures in array that you want 
      ;; preserved, bind *print-circle* to T here, too.
      ;; You might also want to bind *read-eval* to nil here,
      ;; if you are going to bind it to nil when reading.
      (write my-array stream))))

> But now the question is how do I get it back?

(defun read-my-data (filename)
  (with-open-file (stream filename)
    (with-standard-io-syntax
      ;; You might want to bind *read-eval* to nil here,
      ;; for security reasons.  See HyperSpec for detail.
      (read stream))))

This function will return the read-in array.

> Is there something like a *read-array* command, and if so, what do I
> need to type.  I can't seem to find it anywhere.

See the HyperSpec, chapter 21 (Printer), 22 (Reader) and 20 (Streams).
You might also want to skim a couple of the other chapters as well.

The HyperSpec is availabe at

  http://www.xanalys.com/software_tools/reference/HyperSpec/

Regs, Pierre.

-- 
Pierre R. Mai <····@acm.org>                    http://www.pmsf.de/pmai/
 The most likely way for the world to be destroyed, most experts agree,
 is by accident. That's where we come in; we're computer professionals.
 We cause accidents.                           -- Nathaniel Borenstein
From: Alexey Dejneka
Subject: Re: Some Progress!
Date: 
Message-ID: <m3u1wcbdb9.fsf@comail.ru>
Hello,

··········@hotmail.com (Nonzero) writes:
> (setq data-file (open "array-data.dat" :direction output
                                                    ^^^^^^
                                         should be :output
>                                        :if-exists :overwrite
>                                        :if-does-not-exist :create))
> 
> (let ((*print-array* t))
>      (print my-array data-file))
> 
> This allows me to write my array to a file.
> 
> Whewph!
> 
> But now the question is how do I get it back?

(with-open-file (data-file "array-data.dat" :direction :input)
                (setq *my-array* (read data-file)))

Don't use global variable names without *-s around (even in a REPL dialog).

Regards,
Alexey Dejneka

-- 
(loop with nil = t do ...)