[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Help needed for defining a 2-D table

   Date: 	Sun, 9 Dec 90 14:05:19 EST
   From: bhuiyan@skorpio.usask.ca

   I require a two dimensional table for my application.

In order to do this, you will need to define a way to map from
your data (perhaps a 2-d array?) to the cells of the table.
You do this by defining an obfun for CELL-CONTENTS which looks
up the appropriate element of your data.

It's up to you to associate the data with the table-dialog-item.

*SEQUENCE-DIALOG-ITEM* accomplishes this by having an instance
variable TABLE-SEQUENCE, an init-list keyword :TABLE-SEQUENCE,
and a definition for CELL-CONTENTS which calls ELT on the

Assuming you want to use a 2-d array, you could use something
like the following (which has *not* been tested!):

(defobject *2-d-table* *table-dialog-item*)

(defobfun (exist *2-d-table*) (init-list)
  (have 'my-array (or (getf init-list :table-array nil)
                      (make-array (getf init-list :table-dimensions '(5 5)))))
  (usual-exist init-list))

(defobfun (cell-contents *2-d-table*) (h &optional v)
  (let* ((point (make-point h v))
         (h (point-h point))
         (v (point-v point)))
   (aref (objvar my-array) h v)))

I hope this helps.