Index: txtdb/nada3/RunsToDo.dat ================================================================== --- txtdb/nada3/RunsToDo.dat +++ txtdb/nada3/RunsToDo.dat @@ -1,3 +1,3 @@ -[a/b/c] -ww12a all +[ww12a] +b/c/d yes Index: txtdb/nada3/sheet-names.cfg ================================================================== --- txtdb/nada3/sheet-names.cfg +++ txtdb/nada3/sheet-names.cfg @@ -1,3 +1,4 @@ -RunsToDo +First_Sheet Second-sheet -First_Sheet +RunsToDo +RunsToLock Index: txtdb/nada3/sxml/RunsToDo.sxml ================================================================== --- txtdb/nada3/sxml/RunsToDo.sxml +++ txtdb/nada3/sxml/RunsToDo.sxml @@ -85,13 +85,13 @@ (http://www.gnumeric.org/v10.dtd:Rows (@ (DefaultSizePts "12.1")) (http://www.gnumeric.org/v10.dtd:RowInfo (@ (Unit "13.5") (No "0") (Count "2")))) (http://www.gnumeric.org/v10.dtd:Selections - (@ (CursorRow "0") (CursorCol "0")) + (@ (CursorRow "2") (CursorCol "1")) (http://www.gnumeric.org/v10.dtd:Selection - (@ (startRow "0") (startCol "0") (endRow "0") (endCol "0")))) + (@ (startRow "2") (startCol "1") (endRow "2") (endCol "1")))) (http://www.gnumeric.org/v10.dtd:SheetLayout (@ (TopLeft "A1"))) (http://www.gnumeric.org/v10.dtd:Solver (@ (ProgramR "0") (ProblemType "0") (NonNeg "1") Index: txtdb/nada3/sxml/Second-sheet.sxml ================================================================== --- txtdb/nada3/sxml/Second-sheet.sxml +++ txtdb/nada3/sxml/Second-sheet.sxml @@ -302,13 +302,13 @@ (http://www.gnumeric.org/v10.dtd:Rows (@ (DefaultSizePts "12.1")) (http://www.gnumeric.org/v10.dtd:RowInfo (@ (Unit "13.5") (No "0") (Count "20")))) (http://www.gnumeric.org/v10.dtd:Selections - (@ (CursorRow "23") (CursorCol "8")) + (@ (CursorRow "0") (CursorCol "0")) (http://www.gnumeric.org/v10.dtd:Selection - (@ (startRow "23") (startCol "8") (endRow "23") (endCol "8")))) + (@ (startRow "0") (startCol "0") (endRow "0") (endCol "0")))) (http://www.gnumeric.org/v10.dtd:SheetLayout (@ (TopLeft "A1"))) (http://www.gnumeric.org/v10.dtd:Solver (@ (ProgramR "0") (ProblemType "0") (NonNeg "1") Index: txtdb/nada3/sxml/sheets.sxml ================================================================== --- txtdb/nada3/sxml/sheets.sxml +++ txtdb/nada3/sxml/sheets.sxml @@ -26,13 +26,13 @@ (http://www.gnumeric.org/v10.dtd:name "WorkbookView::is_protected") (http://www.gnumeric.org/v10.dtd:value "FALSE"))) (urn:oasis:names:tc:opendocument:xmlns:office:1.0:document-meta (@ (urn:oasis:names:tc:opendocument:xmlns:office:1.0:version "1.2")) (urn:oasis:names:tc:opendocument:xmlns:office:1.0:meta - (http://purl.org/dc/elements/1.1/:date "2013-07-15T03:52:43Z") + (http://purl.org/dc/elements/1.1/:date "2013-07-15T04:32:47Z") (urn:oasis:names:tc:opendocument:xmlns:meta:1.0:creation-date - "2013-07-15T03:51:51Z"))) + "2013-07-15T04:32:37Z"))) (http://www.gnumeric.org/v10.dtd:Calculation (@ (MaxIterations "100") (ManualRecalc "0") (IterationTolerance "0.001") (FloatRadix "2") @@ -48,8 +48,12 @@ (http://www.gnumeric.org/v10.dtd:Cols "256")) "Second-sheet") (http://www.gnumeric.org/v10.dtd:SheetName (@ (http://www.gnumeric.org/v10.dtd:Rows "65536") (http://www.gnumeric.org/v10.dtd:Cols "256")) - "RunsToDo")) + "RunsToDo") + (http://www.gnumeric.org/v10.dtd:SheetName + (@ (http://www.gnumeric.org/v10.dtd:Rows "65536") + (http://www.gnumeric.org/v10.dtd:Cols "256")) + "RunsToLock")) (http://www.gnumeric.org/v10.dtd:Geometry (@ (Width "1440") (Height "647"))) - (http://www.gnumeric.org/v10.dtd:UIData (@ (SelectedTab "1")))) + (http://www.gnumeric.org/v10.dtd:UIData (@ (SelectedTab "3")))) Index: txtdb/txtdb.scm ================================================================== --- txtdb/txtdb.scm +++ txtdb/txtdb.scm @@ -301,31 +301,78 @@ new-rownames new-colnames (if (> curr-rownum rownum) curr-rownum rownum) (if (> curr-colnum colnum) curr-colnum colnum) )))))) +(define help + (conc "Usage: txtdb action params ... + +Note: txtdbdir is a path to the directory containg sheet-names.cfg + + import filename.gnumeric txtdbdir : Import a gnumeric file into a txt db directory + edit txtdbdir : Edit a txtdbdir using gnumeric. + lookup txtdbdir sheetname row col : Look up a value in the text db + json txtdbdir : Print the db as list of lists json data + +Part of the Megatest tool suite. Learn more at http://www.kiatoa.com/fossils/megatest")) + +(define (lookup path sheet row col) + (let ((fname (conc path "/" sheet ".dat"))) + (if (file-exists? fname) + (let ((dat (read-dat fname))) + (if (null? dat) + #f + (let loop ((hed (car dat)) + (tal (cdr dat))) + (if (and (equal? row (car hed)) + (equal? col (cadr hed))) + (caddr hed) + (if (null? tal) + #f + (loop (car tal)(cdr tal))))))) + #f))) + (define (edit-txtdb path) (let* ((dbname (pathname-strip-directory path)) (tmpf (conc (create-temporary-file dbname) ".gnumeric"))) - (txtdb-export path tmpf) + (if (file-exists? (conc path "/sheet-names.cfg")) + (txtdb-export path tmpf)) (let ((pid (process-run "gnumeric" (list tmpf)))) (process-wait pid) (import-gnumeric-file tmpf path)))) - -(define (process-action action . param) - (case (string->symbol action) - ((edit) - (edit-txtdb (car param))))) +(define (process-action action-str . param) + (let ((num-params (length param)) + (action (string->symbol action-str))) + (cond + ((eq? num-params 1) + (case action + ((edit) + (edit-txtdb (car param))))) + ((eq? num-params 2) + (case action + ((import) + (let ((fname (car param)) + (targname (cadr param))) + (import-gnumeric-file fname targname))))) + ((eq? num-params 4) + (case action + ((lookup) ;; path section row col + (let ((res (lookup (car param)(cadr param)(caddr param)(cadddr param)))) + (if res + (print res) + (begin + (print "") + (exit 1)))))))))) (define (main) (let* ((args (argv)) (prog (car args)) (rema (cdr args))) (cond ((null? rema)(print help)) - ((eq? (length rema) 2) + ((>= (length rema) 2) (apply process-action (car rema)(cdr rema))) (else (print help))))) (main)