Index: dashboard-tests.scm ================================================================== --- dashboard-tests.scm +++ dashboard-tests.scm @@ -372,11 +372,14 @@ (let ((s (vector-ref x 2))) (if (number? s)(seconds->time-string s) s)) (vector-ref x 3) (vector-ref x 4))) (sort (hash-table-values comprsteps) - (lambda (a b)(< (vector-ref a 1)(vector-ref b 1)))))) + (lambda (a b) + (if (and (number? a)(number? b)) + (< (vector-ref a 1)(vector-ref b 1)) + #t))))) "\n"))) (if (not (equal? currval newval)) (iup:attribute-set! stepsdat "TITLE" newval))))) stepsdat))))) (iup:show self) Index: ods.scm ================================================================== --- ods.scm +++ ods.scm @@ -126,33 +126,37 @@ RNIhkg6RdIikQyQdIukQSYdIOkTSIZIOkXSIpEMkHSLpEEmHSDpE0iGSDpF0 iKRDJB0i6RBJh0g6RNIhkg6RdIikQyQdIukQSYdIOkTSIZIOkXSIpEMkHSLp EEmHSDpE0iGSDpF0iKRDJB0i6RBJh+gv8TgE/jVPQbMAAAAASUVORK5CYII= ===="))))) -(define (ods:sheet sheetname content) - (conc "\n" - content - "\n")) +;; sheetdat is '("sheetname" (r1c1 r2c2 ...)(r2c1 r2c2 ...) ...) +(define (ods:sheet sheetdat) + (let ((name (car sheetdat)) + (rows (cdr sheetdat))) + (conc "\n" + (conc (ods:column) + (apply conc (map ods:row rows))) + ""))) ;; seems to be called once at top of each sheet, i.e. a column of rows (define (ods:column) "\n") ;; cells is a list of ... -(define (ods:row . cells) +(define (ods:row cells) (apply conc (cons "\n" - (append cells (list "\n"))))) + (append (map ods:cell cells) + (list "\n"))))) ;; types are "string" or "float" -(define (ods:cell value . params) - (let ((type (if (not (null? params)) - (car params) - (cond - ((string? value) "string") - ((number? value) "float") - (else "string"))))) +(define (ods:cell value) + (let ((type (cond + ((string? value) "string") + ((symbol? value) "string") + ((number? value) "float") + (else "string")))) (conc "" "\n" "" value "" "\n" "" "\n"))) ;; create the directories @@ -176,17 +180,17 @@ (lines (cadr fdat))) (with-output-to-file (conc path "/" name) (lambda () (for-each (lambda (line) - (print line)) + (display line)) lines))))) ods:files)) ;; data format: ;; '( (sheet1 (r1c1 r1c2 r1c3 ...) -;; (r2c1 r2c3 r2c3 ...) +;; (r2c1 r2c3 r2c3 ...) ) ;; (sheet2 ( ... ) ;; ( ... ) ) ) (define (ods:list->ods path fname data) (if (not (file-exists? path)) (print "ERROR: path to create ods data must pre-exist") @@ -195,25 +199,11 @@ (lambda () (ods:construct-dir path) (ods:add-non-content-files path) (ods:make-thumbnail path) (map display ods:content-header) - (print - (ods:sheet - "Sheet1" - (conc - (ods:column) - (ods:row - (ods:cell "Row 1,A") - (ods:cell "Row 1,B")) - (ods:row - (ods:cell "Row 2,A") - (ods:cell "Row 2,B")))) - (ods:sheet - "Sheet2" - (conc - (ods:column) - (ods:row - (ods:cell "Sheet 2 contents"))))) + ;; process each sheet + (map print + (map ods:sheet data)) (map display ods:content-footer))) (system (conc "cd " path "; zip " fname " -n mimetype mimetype `find . |grep -v mimetype`"))))) - +