;; Print the contents of the BOM table to a file ;; Quick and dirty, using sample code provided by Wolfgang ;; ChrisE, 12.03.03 (in-package :CHRIS) (use-package :OLI) (sd-defdialog 'print_bom :dialog-title "Stueckliste drucken" :variables '( (O_FILE :value-type :filename :title "The File" :initialdirectory (sd-inq-temp-dir) :direction :output :if-exists :overwrite :initialpattern "*.csv" :filename-incl-path t ) ) :ok-action '(l-doit) :local-functions '( (l-doit () (sd-logical-table-contents-to-csv (sd-get-display-table-logical-table "AM-BOM-DATA-DTAB") (first O_FILE) ) ;; Open the file when on Windows into the registered application (when (eql (sd-inq-platform) :nt) (SD-SYS-BACKGROUND-JOB (format nil "cmd /e:on /c ~S" (sd-convert-filename-to-platform (first O_FILE)))) ) ) ) ) (defun sd-logical-table-contents-to-csv (ltab fname) (when (sd-logical-table-p ltab) (let (row hrow buffer) (with-open-file (fo fname :direction :output) ;; Output the column headers (setq hrow (sd-get-logical-table-column-identifiers ltab)) (format fo "~A~{;~A~}~%" (car hrow) (rest hrow)) ;; Output the column values (dotimes (i (sd-get-logical-table-number-of-rows ltab)) (setq buffer "") (dolist (col hrow) (setq buffer (concatenate 'string buffer (sd-read-logical-table-cell ltab :row i :column col) ";" )) ) (format fo "~A~%" buffer) ;;(setf row (sd-read-logical-table-row ltab :row i)) ;;(display row) ;;(format fo "~A~{;~A~}~%" (car row) (rest row)) ); dotimes ); with ); let ); when ); defun