source: trunk/bindings/swig/nxtest.scm @ 1822

Revision 211, 1.8 KB checked in by nexus, 9 years ago (diff)
  • Fixed a bug which caused foreign HDF-5's not to be read properly
  • Fixed a bug in NXgetnextentry which prevented reinitialising searches and nested searches.
  • Adapted the jnexus stuff to NAPI-2.0
  • Added the swig interface to NeXus to the source tree
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1;--------------------------------------------------------------------------
2; scheme reading of a NeXus file
3;
4; this version for mzscheme
5;
6; Mark Koennecke, October 2002
7;--------------------------------------------------------------------------
8
9(load-extension "nxscheme.so")
10(load "asciidblib.scm") ; for string-split
11
12;------------------- print attributes -------------------------------------
13(define (print-attrib fd)
14  (let ( (att (nx-getnextattr fd #\@)) )
15    (if (< 2 (string-length att))
16        (let ( (splitlist (string-split att (list #\@))) )
17          (display (list-ref splitlist 0))
18          (display "=")
19          (display (get-nxds-text (nx-getattr fd (list-ref splitlist 0)
20                               (string->number (list-ref splitlist 2))
21                               (string->number (list-ref splitlist 1)))))
22          (newline)
23          (print-attrib fd) ) ) ) )
24;----------------------- print a 2d dataset---------------------------
25(define (print2d dataset)
26  (letrec ( (ydim (get-nxds-dim dataset 1))
27         (printRow (lambda (dataset yval xdim count)
28             (if (>= count xdim)
29                 (newline)
30                 (begin
31                   (display (get-nxds-value dataset count yval))
32                   (display "  ")
33                   (printRow dataset yval xdim (+ count 1))
34                 )) ))
35         (printWhole (lambda (dataset ydim count)
36               (let ( (xdim (get-nxds-dim dataset 0)) )
37                 (if (>= count ydim)
38                     (newline)
39                     (begin
40                       (printRow dataset count xdim 0)
41                       (printWhole dataset ydim (+ count 1)) ) ) ) )) )
42    (printWhole dataset ydim 0) ) )
43;======================================================================
44(define fd (nx-open "nxinter.hdf" (nxacc-read)))
45(print-attrib fd)
46
47(nx-opengroup fd "fish" "NXentry")
48(nx-opendata fd "fish")
49(let
50    ( (ds (nx-getdata fd)) )
51  (print2d ds)
52  (drop-nxds ds) )
53(nx-closedata fd)
54(nx-closegroup fd)
55(nx-close fd)
56
Note: See TracBrowser for help on using the repository browser.