Artifact
d2f3133988d062e0d9b4af699c8aac49404e9cc5:
0000: 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ;;==============
0010: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
0020: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
0030: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
0040: 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b 20 43 6f 70 79 ========.;; Copy
0050: 72 69 67 68 74 20 32 30 30 36 2d 32 30 31 33 2c right 2006-2013,
0060: 20 4d 61 74 74 68 65 77 20 57 65 6c 6c 61 6e 64 Matthew Welland
0070: 2e 0a 3b 3b 20 0a 3b 3b 20 54 68 69 73 20 66 69 ..;; .;; This fi
0080: 6c 65 20 69 73 20 70 61 72 74 20 6f 66 20 4d 65 le is part of Me
0090: 67 61 74 65 73 74 2e 0a 3b 3b 20 0a 3b 3b 20 20 gatest..;; .;;
00a0: 20 20 20 4d 65 67 61 74 65 73 74 20 69 73 20 66 Megatest is f
00b0: 72 65 65 20 73 6f 66 74 77 61 72 65 3a 20 79 6f ree software: yo
00c0: 75 20 63 61 6e 20 72 65 64 69 73 74 72 69 62 75 u can redistribu
00d0: 74 65 20 69 74 20 61 6e 64 2f 6f 72 20 6d 6f 64 te it and/or mod
00e0: 69 66 79 0a 3b 3b 20 20 20 20 20 69 74 20 75 6e ify.;; it un
00f0: 64 65 72 20 74 68 65 20 74 65 72 6d 73 20 6f 66 der the terms of
0100: 20 74 68 65 20 47 4e 55 20 47 65 6e 65 72 61 6c the GNU General
0110: 20 50 75 62 6c 69 63 20 4c 69 63 65 6e 73 65 20 Public License
0120: 61 73 20 70 75 62 6c 69 73 68 65 64 20 62 79 0a as published by.
0130: 3b 3b 20 20 20 20 20 74 68 65 20 46 72 65 65 20 ;; the Free
0140: 53 6f 66 74 77 61 72 65 20 46 6f 75 6e 64 61 74 Software Foundat
0150: 69 6f 6e 2c 20 65 69 74 68 65 72 20 76 65 72 73 ion, either vers
0160: 69 6f 6e 20 33 20 6f 66 20 74 68 65 20 4c 69 63 ion 3 of the Lic
0170: 65 6e 73 65 2c 20 6f 72 0a 3b 3b 20 20 20 20 20 ense, or.;;
0180: 28 61 74 20 79 6f 75 72 20 6f 70 74 69 6f 6e 29 (at your option)
0190: 20 61 6e 79 20 6c 61 74 65 72 20 76 65 72 73 69 any later versi
01a0: 6f 6e 2e 0a 3b 3b 20 0a 3b 3b 20 20 20 20 20 4d on..;; .;; M
01b0: 65 67 61 74 65 73 74 20 69 73 20 64 69 73 74 72 egatest is distr
01c0: 69 62 75 74 65 64 20 69 6e 20 74 68 65 20 68 6f ibuted in the ho
01d0: 70 65 20 74 68 61 74 20 69 74 20 77 69 6c 6c 20 pe that it will
01e0: 62 65 20 75 73 65 66 75 6c 2c 0a 3b 3b 20 20 20 be useful,.;;
01f0: 20 20 62 75 74 20 57 49 54 48 4f 55 54 20 41 4e but WITHOUT AN
0200: 59 20 57 41 52 52 41 4e 54 59 3b 20 77 69 74 68 Y WARRANTY; with
0210: 6f 75 74 20 65 76 65 6e 20 74 68 65 20 69 6d 70 out even the imp
0220: 6c 69 65 64 20 77 61 72 72 61 6e 74 79 20 6f 66 lied warranty of
0230: 0a 3b 3b 20 20 20 20 20 4d 45 52 43 48 41 4e 54 .;; MERCHANT
0240: 41 42 49 4c 49 54 59 20 6f 72 20 46 49 54 4e 45 ABILITY or FITNE
0250: 53 53 20 46 4f 52 20 41 20 50 41 52 54 49 43 55 SS FOR A PARTICU
0260: 4c 41 52 20 50 55 52 50 4f 53 45 2e 20 20 53 65 LAR PURPOSE. Se
0270: 65 20 74 68 65 0a 3b 3b 20 20 20 20 20 47 4e 55 e the.;; GNU
0280: 20 47 65 6e 65 72 61 6c 20 50 75 62 6c 69 63 20 General Public
0290: 4c 69 63 65 6e 73 65 20 66 6f 72 20 6d 6f 72 65 License for more
02a0: 20 64 65 74 61 69 6c 73 2e 0a 3b 3b 20 0a 3b 3b details..;; .;;
02b0: 20 20 20 20 20 59 6f 75 20 73 68 6f 75 6c 64 20 You should
02c0: 68 61 76 65 20 72 65 63 65 69 76 65 64 20 61 20 have received a
02d0: 63 6f 70 79 20 6f 66 20 74 68 65 20 47 4e 55 20 copy of the GNU
02e0: 47 65 6e 65 72 61 6c 20 50 75 62 6c 69 63 20 4c General Public L
02f0: 69 63 65 6e 73 65 0a 3b 3b 20 20 20 20 20 61 6c icense.;; al
0300: 6f 6e 67 20 77 69 74 68 20 4d 65 67 61 74 65 73 ong with Megates
0310: 74 2e 20 20 49 66 20 6e 6f 74 2c 20 73 65 65 20 t. If not, see
0320: 3c 68 74 74 70 3a 2f 2f 77 77 77 2e 67 6e 75 2e <http://www.gnu.
0330: 6f 72 67 2f 6c 69 63 65 6e 73 65 73 2f 3e 2e 0a org/licenses/>..
0340: 3b 3b 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ;;.;;===========
0350: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
0360: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
0370: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
0380: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a 28 69 6d ===========..(im
0390: 70 6f 72 74 20 66 6f 72 6d 61 74 29 0a 3b 3b 20 port format).;;
03a0: 28 69 6d 70 6f 72 74 20 69 75 70 29 0a 28 69 6d (import iup).(im
03b0: 70 6f 72 74 20 28 70 72 65 66 69 78 20 69 75 70 port (prefix iup
03c0: 20 69 75 70 3a 29 29 0a 28 69 6d 70 6f 72 74 20 iup:)).(import
03d0: 63 61 6e 76 61 73 2d 64 72 61 77 29 0a 0a 28 69 canvas-draw)..(i
03e0: 6d 70 6f 72 74 20 73 71 6c 69 74 65 33 20 73 72 mport sqlite3 sr
03f0: 66 69 2d 31 0a 09 63 68 69 63 6b 65 6e 2e 66 69 fi-1..chicken.fi
0400: 6c 65 2e 70 6f 73 69 78 0a 09 72 65 67 65 78 20 le.posix..regex
0410: 72 65 67 65 78 2d 63 61 73 65 20 73 72 66 69 2d regex-case srfi-
0420: 36 39 29 0a 28 69 6d 70 6f 72 74 20 28 70 72 65 69).(import (pre
0430: 66 69 78 20 73 71 6c 69 74 65 33 20 73 71 6c 69 fix sqlite3 sqli
0440: 74 65 33 3a 29 29 0a 0a 28 64 65 63 6c 61 72 65 te3:))..(declare
0450: 20 28 75 6e 69 74 20 74 72 65 65 29 29 0a 28 64 (unit tree)).(d
0460: 65 63 6c 61 72 65 20 28 75 73 65 73 20 6d 74 61 eclare (uses mta
0470: 72 67 73 29 29 0a 28 64 65 63 6c 61 72 65 20 28 rgs)).(declare (
0480: 75 73 65 73 20 6d 74 76 65 72 29 29 0a 28 64 65 uses mtver)).(de
0490: 63 6c 61 72 65 20 28 75 73 65 73 20 6c 61 75 6e clare (uses laun
04a0: 63 68 29 29 0a 3b 3b 20 28 64 65 63 6c 61 72 65 ch)).;; (declare
04b0: 20 28 75 73 65 73 20 6d 65 67 61 74 65 73 74 2d (uses megatest-
04c0: 76 65 72 73 69 6f 6e 29 29 0a 28 64 65 63 6c 61 version)).(decla
04d0: 72 65 20 28 75 73 65 73 20 67 75 74 69 6c 73 29 re (uses gutils)
04e0: 29 0a 28 64 65 63 6c 61 72 65 20 28 75 73 65 73 ).(declare (uses
04f0: 20 64 62 6d 6f 64 29 29 0a 28 64 65 63 6c 61 72 dbmod)).(declar
0500: 65 20 28 75 73 65 73 20 73 65 72 76 65 72 6d 6f e (uses servermo
0510: 64 29 29 0a 3b 3b 20 28 64 65 63 6c 61 72 65 20 d)).;; (declare
0520: 28 75 73 65 73 20 73 79 6e 63 68 61 73 68 29 29 (uses synchash))
0530: 0a 28 64 65 63 6c 61 72 65 20 28 75 73 65 73 20 .(declare (uses
0540: 64 63 6f 6d 6d 6f 6e 29 29 0a 0a 28 69 6d 70 6f dcommon))..(impo
0550: 72 74 20 6d 74 76 65 72 29 0a 3b 3b 20 28 69 6e rt mtver).;; (in
0560: 63 6c 75 64 65 20 22 6d 65 67 61 74 65 73 74 2d clude "megatest-
0570: 76 65 72 73 69 6f 6e 2e 73 63 6d 22 29 0a 28 69 version.scm").(i
0580: 6e 63 6c 75 64 65 20 22 63 6f 6d 6d 6f 6e 5f 72 nclude "common_r
0590: 65 63 6f 72 64 73 2e 73 63 6d 22 29 0a 28 69 6e ecords.scm").(in
05a0: 63 6c 75 64 65 20 22 64 62 5f 72 65 63 6f 72 64 clude "db_record
05b0: 73 2e 73 63 6d 22 29 0a 28 69 6e 63 6c 75 64 65 s.scm").(include
05c0: 20 22 6b 65 79 5f 72 65 63 6f 72 64 73 2e 73 63 "key_records.sc
05d0: 6d 22 29 0a 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d m")..;;=========
05e0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
05f0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
0600: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
0610: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b =============.;;
0620: 20 54 20 52 20 45 20 45 20 20 20 53 20 54 20 55 T R E E S T U
0630: 20 46 20 46 20 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d F F .;;========
0640: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
0650: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
0660: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
0670: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a ==============..
0680: 3b 3b 20 70 61 74 68 20 69 73 20 61 20 6c 69 73 ;; path is a lis
0690: 74 20 6f 66 20 6e 6f 64 65 73 2c 20 65 61 63 68 t of nodes, each
06a0: 20 74 68 65 20 63 68 69 6c 64 20 6f 66 20 74 68 the child of th
06b0: 65 20 70 72 65 76 69 6f 75 73 0a 3b 3b 20 74 68 e previous.;; th
06c0: 69 73 20 72 6f 75 74 69 6e 65 20 72 65 74 75 72 is routine retur
06d0: 6e 73 20 74 68 65 20 69 64 20 73 6f 20 61 6e 6f ns the id so ano
06e0: 74 68 65 72 20 6e 6f 64 65 20 63 61 6e 20 62 65 ther node can be
06f0: 20 61 64 64 65 64 0a 3b 3b 20 65 69 74 68 65 72 added.;; either
0700: 20 61 73 20 61 20 6c 65 61 66 20 6f 72 20 61 73 as a leaf or as
0710: 20 61 20 62 72 61 6e 63 68 0a 3b 3b 0a 3b 3b 20 a branch.;;.;;
0720: 42 55 47 3a 20 54 68 69 73 20 6e 65 65 64 73 20 BUG: This needs
0730: 61 20 73 74 6f 70 20 73 65 6e 73 6f 72 20 66 6f a stop sensor fo
0740: 72 20 77 68 65 6e 20 61 20 62 72 61 6e 63 68 20 r when a branch
0750: 69 73 20 65 78 68 61 75 73 74 65 64 0a 3b 3b 0a is exhausted.;;.
0760: 28 64 65 66 69 6e 65 20 28 74 72 65 65 3a 66 69 (define (tree:fi
0770: 6e 64 2d 6e 6f 64 65 20 6f 62 6a 20 70 61 74 68 nd-node obj path
0780: 29 0a 20 20 3b 3b 20 73 74 61 72 74 20 61 74 20 ). ;; start at
0790: 74 68 65 20 62 61 73 65 20 6f 66 20 74 68 65 20 the base of the
07a0: 74 72 65 65 0a 20 20 28 69 66 20 28 6e 75 6c 6c tree. (if (null
07b0: 3f 20 70 61 74 68 29 0a 20 20 20 20 20 20 23 66 ? path). #f
07c0: 20 3b 3b 20 6f 72 20 30 20 3f 3f 3f 3f 0a 20 20 ;; or 0 ????.
07d0: 20 20 20 20 28 6c 65 74 20 6c 6f 6f 70 20 28 28 (let loop ((
07e0: 68 65 64 20 20 20 20 20 20 28 63 61 72 20 70 61 hed (car pa
07f0: 74 68 29 29 0a 09 09 20 28 74 61 6c 20 20 20 20 th))... (tal
0800: 20 20 28 63 64 72 20 70 61 74 68 29 29 0a 09 09 (cdr path))...
0810: 20 28 64 65 70 74 68 20 20 20 20 30 29 0a 09 09 (depth 0)...
0820: 20 28 6e 6f 64 65 6e 75 6d 20 20 30 29 29 0a 09 (nodenum 0))..
0830: 3b 3b 20 6e 6f 64 65 73 20 69 6e 20 69 75 70 20 ;; nodes in iup
0840: 74 72 65 65 20 61 72 65 20 31 30 30 25 20 73 65 tree are 100% se
0850: 71 75 65 6e 74 69 61 6c 20 73 6f 20 69 74 65 72 quential so iter
0860: 61 74 65 20 6f 76 65 72 20 6e 6f 64 65 6e 75 6d ate over nodenum
0870: 0a 09 28 69 66 20 28 69 75 70 3a 61 74 74 72 69 ..(if (iup:attri
0880: 62 75 74 65 20 6f 62 6a 20 28 63 6f 6e 63 20 22 bute obj (conc "
0890: 44 45 50 54 48 22 20 6e 6f 64 65 6e 75 6d 29 29 DEPTH" nodenum))
08a0: 20 3b 3b 20 65 6e 64 20 77 68 65 6e 20 6e 6f 20 ;; end when no
08b0: 6d 6f 72 65 20 6e 6f 64 65 73 0a 09 20 20 20 20 more nodes..
08c0: 28 6c 65 74 20 28 28 6e 6f 64 65 2d 64 65 70 74 (let ((node-dept
08d0: 68 20 28 73 74 72 69 6e 67 2d 3e 6e 75 6d 62 65 h (string->numbe
08e0: 72 20 28 69 75 70 3a 61 74 74 72 69 62 75 74 65 r (iup:attribute
08f0: 20 6f 62 6a 20 28 63 6f 6e 63 20 22 44 45 50 54 obj (conc "DEPT
0900: 48 22 20 6e 6f 64 65 6e 75 6d 29 29 29 29 0a 09 H" nodenum))))..
0910: 09 20 20 28 6e 6f 64 65 2d 74 69 74 6c 65 20 28 . (node-title (
0920: 69 75 70 3a 61 74 74 72 69 62 75 74 65 20 6f 62 iup:attribute ob
0930: 6a 20 28 63 6f 6e 63 20 22 54 49 54 4c 45 22 20 j (conc "TITLE"
0940: 6e 6f 64 65 6e 75 6d 29 29 29 29 0a 09 20 20 20 nodenum))))..
0950: 20 20 20 28 69 66 20 28 61 6e 64 20 28 65 71 75 (if (and (equ
0960: 61 6c 3f 20 64 65 70 74 68 20 6e 6f 64 65 2d 64 al? depth node-d
0970: 65 70 74 68 29 0a 09 09 20 20 20 20 20 20 20 28 epth)... (
0980: 65 71 75 61 6c 3f 20 68 65 64 20 20 20 6e 6f 64 equal? hed nod
0990: 65 2d 74 69 74 6c 65 29 29 20 3b 3b 20 79 65 70 e-title)) ;; yep
09a0: 2c 20 74 68 69 73 20 69 73 20 74 68 65 20 6f 6e , this is the on
09b0: 65 21 0a 09 09 20 20 28 69 66 20 28 6e 75 6c 6c e!... (if (null
09c0: 3f 20 74 61 6c 29 20 3b 3b 20 65 6e 64 20 6f 66 ? tal) ;; end of
09d0: 20 74 68 65 20 6c 69 6e 65 0a 09 09 20 20 20 20 the line...
09e0: 20 20 6e 6f 64 65 6e 75 6d 0a 09 09 20 20 20 20 nodenum...
09f0: 20 20 28 6c 6f 6f 70 20 28 63 61 72 20 74 61 6c (loop (car tal
0a00: 29 28 63 64 72 20 74 61 6c 29 28 2b 20 64 65 70 )(cdr tal)(+ dep
0a10: 74 68 20 31 29 28 2b 20 31 20 6e 6f 64 65 6e 75 th 1)(+ 1 nodenu
0a20: 6d 29 29 29 0a 09 09 20 20 3b 3b 20 74 68 69 73 m)))... ;; this
0a30: 20 69 73 20 74 68 65 20 63 61 73 65 20 77 68 65 is the case whe
0a40: 72 65 20 77 65 20 66 6f 75 6e 64 20 70 61 72 74 re we found part
0a50: 20 6f 66 20 74 68 65 20 68 69 65 72 61 72 63 68 of the hierarch
0a60: 79 20 62 75 74 20 6e 6f 74 20 0a 09 09 20 20 3b y but not ... ;
0a70: 3b 20 61 6c 6c 20 6f 66 20 69 74 2c 20 69 2e 65 ; all of it, i.e
0a80: 2e 20 74 68 65 20 6e 6f 64 65 2d 64 65 70 74 68 . the node-depth
0a90: 20 77 65 6e 74 20 66 72 6f 6d 20 64 65 65 70 20 went from deep
0aa0: 74 6f 20 6c 65 73 73 20 64 65 65 70 0a 09 09 20 to less deep...
0ab0: 20 28 69 66 20 28 3e 20 64 65 70 74 68 20 6e 6f (if (> depth no
0ac0: 64 65 2d 64 65 70 74 68 29 20 3b 3b 20 28 2b 20 de-depth) ;; (+
0ad0: 31 20 6e 6f 64 65 2d 64 65 70 74 68 29 29 0a 09 1 node-depth))..
0ae0: 09 20 20 20 20 20 20 23 66 0a 09 09 20 20 20 20 . #f...
0af0: 20 20 28 6c 6f 6f 70 20 68 65 64 20 74 61 6c 20 (loop hed tal
0b00: 64 65 70 74 68 20 28 2b 20 6e 6f 64 65 6e 75 6d depth (+ nodenum
0b10: 20 31 29 29 29 29 29 0a 09 20 20 20 20 23 66 29 1))))).. #f)
0b20: 29 29 29 0a 0a 3b 3b 20 74 6f 70 20 69 73 20 74 )))..;; top is t
0b30: 68 65 20 74 6f 70 20 6e 6f 64 65 20 6e 61 6d 65 he top node name
0b40: 20 7a 65 72 6f 65 74 68 20 6e 6f 64 65 20 56 41 zeroeth node VA
0b50: 4c 55 45 3d 30 0a 28 64 65 66 69 6e 65 20 28 74 LUE=0.(define (t
0b60: 72 65 65 3a 61 64 64 2d 6e 6f 64 65 20 6f 62 6a ree:add-node obj
0b70: 20 74 6f 70 20 6e 6f 64 65 6c 73 74 20 23 21 6b top nodelst #!k
0b80: 65 79 20 28 75 73 65 72 64 61 74 61 20 23 66 29 ey (userdata #f)
0b90: 29 0a 20 20 28 6c 65 74 20 28 28 63 75 72 72 2d ). (let ((curr-
0ba0: 74 6f 70 20 28 69 75 70 3a 61 74 74 72 69 62 75 top (iup:attribu
0bb0: 74 65 20 6f 62 6a 20 22 54 49 54 4c 45 30 22 29 te obj "TITLE0")
0bc0: 29 29 0a 20 20 20 20 28 69 66 20 28 6f 72 20 28 )). (if (or (
0bd0: 6e 6f 74 20 28 73 74 72 69 6e 67 3f 20 63 75 72 not (string? cur
0be0: 72 2d 74 6f 70 29 29 0a 09 20 20 20 20 28 73 74 r-top)).. (st
0bf0: 72 69 6e 67 2d 6e 75 6c 6c 3f 20 63 75 72 72 2d ring-null? curr-
0c00: 74 6f 70 29 0a 09 20 20 20 20 28 73 74 72 69 6e top).. (strin
0c10: 67 2d 6d 61 74 63 68 20 22 5e 5c 5c 73 2a 24 22 g-match "^\\s*$"
0c20: 20 63 75 72 72 2d 74 6f 70 29 29 0a 20 20 20 20 curr-top)).
0c30: 20 20 20 20 20 20 28 69 75 70 3a 61 74 74 72 69 (iup:attri
0c40: 62 75 74 65 2d 73 65 74 21 20 6f 62 6a 20 22 41 bute-set! obj "A
0c50: 44 44 42 52 41 4e 43 48 30 22 20 74 6f 70 29 29 DDBRANCH0" top))
0c60: 0a 0a 0a 20 20 20 20 0a 20 20 20 20 28 63 6f 6e ... . (con
0c70: 64 0a 20 20 20 20 20 28 28 6e 6f 74 20 28 65 71 d. ((not (eq
0c80: 75 61 6c 3f 20 74 6f 70 20 28 69 75 70 3a 61 74 ual? top (iup:at
0c90: 74 72 69 62 75 74 65 20 6f 62 6a 20 22 54 49 54 tribute obj "TIT
0ca0: 4c 45 30 22 29 29 29 0a 20 20 20 20 20 20 28 70 LE0"))). (p
0cb0: 72 69 6e 74 20 22 45 52 52 4f 52 3a 20 74 6f 70 rint "ERROR: top
0cc0: 20 6e 61 6d 65 20 22 20 74 6f 70 20 22 20 64 6f name " top " do
0cd0: 65 73 6e 27 74 20 6d 61 74 63 68 20 22 20 28 69 esn't match " (i
0ce0: 75 70 3a 61 74 74 72 69 62 75 74 65 20 6f 62 6a up:attribute obj
0cf0: 20 22 54 49 54 4c 45 30 22 29 29 29 0a 20 20 20 "TITLE0"))).
0d00: 20 20 28 28 6e 75 6c 6c 3f 20 6e 6f 64 65 6c 73 ((null? nodels
0d10: 74 29 29 0a 20 20 20 20 20 28 65 6c 73 65 0a 20 t)). (else.
0d20: 20 20 20 20 20 28 6c 65 74 20 6c 6f 6f 70 20 28 (let loop (
0d30: 28 68 65 64 20 20 20 20 20 20 28 63 61 72 20 6e (hed (car n
0d40: 6f 64 65 6c 73 74 29 29 0a 09 09 20 28 74 61 6c odelst))... (tal
0d50: 20 20 20 20 20 20 28 63 64 72 20 6e 6f 64 65 6c (cdr nodel
0d60: 73 74 29 29 0a 09 09 20 28 64 65 70 74 68 20 20 st))... (depth
0d70: 20 20 31 29 0a 09 09 20 28 70 61 74 68 6c 20 20 1)... (pathl
0d80: 20 20 28 6c 69 73 74 20 74 6f 70 29 29 29 0a 09 (list top)))..
0d90: 3b 3b 20 42 65 63 61 75 73 65 20 74 68 65 20 74 ;; Because the t
0da0: 72 65 65 20 64 69 61 6c 6f 67 20 63 68 61 6e 67 ree dialog chang
0db0: 65 73 20 6e 6f 64 65 20 6e 75 6d 62 65 72 73 20 es node numbers
0dc0: 77 68 65 6e 0a 09 3b 3b 20 6e 6f 64 65 73 20 61 when..;; nodes a
0dd0: 72 65 20 61 64 64 65 64 20 6f 72 20 72 65 6d 6f re added or remo
0de0: 76 65 64 20 77 65 20 6d 75 73 74 20 6c 6f 6f 6b ved we must look
0df0: 20 75 70 20 6e 6f 64 65 73 0a 09 3b 3b 20 65 61 up nodes..;; ea
0e00: 63 68 20 61 6e 64 20 65 76 65 72 79 20 74 69 6d ch and every tim
0e10: 65 2e 20 30 20 69 73 20 74 68 65 20 74 6f 70 20 e. 0 is the top
0e20: 6e 6f 64 65 20 73 6f 20 64 65 66 61 75 6c 74 0a node so default.
0e30: 09 3b 3b 20 74 6f 20 74 68 61 74 2e 0a 09 28 6c .;; to that...(l
0e40: 65 74 2a 20 28 28 6e 65 77 70 61 74 68 20 20 20 et* ((newpath
0e50: 20 28 61 70 70 65 6e 64 20 70 61 74 68 6c 20 28 (append pathl (
0e60: 6c 69 73 74 20 68 65 64 29 29 29 0a 09 20 20 20 list hed)))..
0e70: 20 20 20 20 28 70 61 72 65 6e 74 6e 6f 64 65 20 (parentnode
0e80: 28 74 72 65 65 3a 66 69 6e 64 2d 6e 6f 64 65 20 (tree:find-node
0e90: 6f 62 6a 20 70 61 74 68 6c 29 29 0a 09 20 20 20 obj pathl))..
0ea0: 20 20 20 20 28 6e 6f 64 65 6e 75 6d 20 20 20 20 (nodenum
0eb0: 28 74 72 65 65 3a 66 69 6e 64 2d 6e 6f 64 65 20 (tree:find-node
0ec0: 6f 62 6a 20 6e 65 77 70 61 74 68 29 29 29 0a 09 obj newpath)))..
0ed0: 20 20 3b 3b 20 41 64 64 20 74 68 65 20 62 72 61 ;; Add the bra
0ee0: 6e 63 68 20 75 6e 64 65 72 20 6c 61 73 74 6e 6f nch under lastno
0ef0: 64 65 20 69 66 20 6e 6f 74 20 66 6f 75 6e 64 0a de if not found.
0f00: 09 20 20 28 69 66 20 28 6e 6f 74 20 6e 6f 64 65 . (if (not node
0f10: 6e 75 6d 29 0a 09 20 20 20 20 20 20 28 62 65 67 num).. (beg
0f20: 69 6e 0a 09 09 28 69 75 70 3a 61 74 74 72 69 62 in...(iup:attrib
0f30: 75 74 65 2d 73 65 74 21 20 6f 62 6a 20 28 63 6f ute-set! obj (co
0f40: 6e 63 20 22 41 44 44 42 52 41 4e 43 48 22 20 70 nc "ADDBRANCH" p
0f50: 61 72 65 6e 74 6e 6f 64 65 29 20 68 65 64 29 0a arentnode) hed).
0f60: 09 09 3b 3b 20 45 52 52 4f 52 3f 20 41 44 44 49 ..;; ERROR? ADDI
0f70: 4e 47 20 44 41 54 41 20 54 4f 20 50 41 52 45 4e NG DATA TO PAREN
0f80: 54 2c 20 44 4f 4e 54 20 57 45 20 57 41 4e 54 20 T, DONT WE WANT
0f90: 49 54 20 4f 4e 20 43 52 45 41 54 45 44 20 4e 4f IT ON CREATED NO
0fa0: 44 45 3f 0a 09 09 28 69 66 20 75 73 65 72 64 61 DE?...(if userda
0fb0: 74 61 0a 09 09 20 20 20 20 28 69 75 70 3a 61 74 ta... (iup:at
0fc0: 74 72 69 62 75 74 65 2d 73 65 74 21 20 6f 62 6a tribute-set! obj
0fd0: 20 28 63 6f 6e 63 20 22 55 53 45 52 44 41 54 41 (conc "USERDATA
0fe0: 22 20 20 20 70 61 72 65 6e 74 6e 6f 64 65 29 20 " parentnode)
0ff0: 75 73 65 72 64 61 74 61 29 29 0a 09 09 28 69 66 userdata))...(if
1000: 20 28 6e 75 6c 6c 3f 20 74 61 6c 29 0a 09 09 20 (null? tal)...
1010: 20 20 20 23 74 0a 09 09 20 20 20 20 3b 3b 20 72 #t... ;; r
1020: 65 73 65 74 20 74 6f 20 74 6f 70 0a 09 09 20 20 eset to top...
1030: 20 20 28 6c 6f 6f 70 20 28 63 61 72 20 6e 6f 64 (loop (car nod
1040: 65 6c 73 74 29 28 63 64 72 20 6e 6f 64 65 6c 73 elst)(cdr nodels
1050: 74 29 20 31 20 28 6c 69 73 74 20 74 6f 70 29 29 t) 1 (list top))
1060: 29 29 20 0a 09 20 20 20 20 20 20 28 69 66 20 28 )) .. (if (
1070: 6e 75 6c 6c 3f 20 74 61 6c 29 20 3b 3b 20 69 66 null? tal) ;; if
1080: 20 6e 75 6c 6c 20 68 65 72 65 20 74 68 65 6e 20 null here then
1090: 74 68 69 73 20 70 61 74 68 20 68 61 73 20 61 6c this path has al
10a0: 72 65 61 64 79 20 62 65 65 6e 20 61 64 64 65 64 ready been added
10b0: 0a 09 09 20 20 23 74 0a 09 09 20 20 28 6c 6f 6f ... #t... (loo
10c0: 70 20 28 63 61 72 20 74 61 6c 29 28 63 64 72 20 p (car tal)(cdr
10d0: 74 61 6c 29 28 2b 20 64 65 70 74 68 20 31 29 20 tal)(+ depth 1)
10e0: 6e 65 77 70 61 74 68 29 29 29 29 29 29 29 29 29 newpath)))))))))
10f0: 0a 0a 28 64 65 66 69 6e 65 20 28 74 72 65 65 3a ..(define (tree:
1100: 6e 6f 64 65 2d 3e 70 61 74 68 20 6f 62 6a 20 6e node->path obj n
1110: 6f 64 65 6e 75 6d 29 0a 20 20 28 6c 65 74 20 6c odenum). (let l
1120: 6f 6f 70 20 28 28 63 75 72 72 6e 6f 64 65 20 30 oop ((currnode 0
1130: 29 0a 09 20 20 20 20 20 28 70 61 74 68 20 20 20 ).. (path
1140: 20 20 27 28 29 29 29 0a 20 20 20 20 28 6c 65 74 '())). (let
1150: 2a 20 28 28 6e 6f 64 65 2d 64 65 70 74 68 20 28 * ((node-depth (
1160: 73 74 72 69 6e 67 2d 3e 6e 75 6d 62 65 72 20 28 string->number (
1170: 69 75 70 3a 61 74 74 72 69 62 75 74 65 20 6f 62 iup:attribute ob
1180: 6a 20 28 63 6f 6e 63 20 22 44 45 50 54 48 22 20 j (conc "DEPTH"
1190: 63 75 72 72 6e 6f 64 65 29 29 29 29 0a 09 20 20 currnode))))..
11a0: 20 28 6e 6f 64 65 2d 74 69 74 6c 65 20 28 69 75 (node-title (iu
11b0: 70 3a 61 74 74 72 69 62 75 74 65 20 6f 62 6a 20 p:attribute obj
11c0: 28 63 6f 6e 63 20 22 54 49 54 4c 45 22 20 63 75 (conc "TITLE" cu
11d0: 72 72 6e 6f 64 65 29 29 29 0a 09 20 20 20 28 74 rrnode))).. (t
11e0: 72 69 6d 70 61 74 68 20 20 20 28 69 66 20 28 61 rimpath (if (a
11f0: 6e 64 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 70 nd (not (null? p
1200: 61 74 68 29 29 0a 09 09 09 09 28 3e 20 28 6c 65 ath)).....(> (le
1210: 6e 67 74 68 20 70 61 74 68 29 20 6e 6f 64 65 2d ngth path) node-
1220: 64 65 70 74 68 29 29 0a 09 09 09 20 20 20 28 74 depth)).... (t
1230: 61 6b 65 20 70 61 74 68 20 6e 6f 64 65 2d 64 65 ake path node-de
1240: 70 74 68 29 0a 09 09 09 20 20 20 70 61 74 68 29 pth).... path)
1250: 29 0a 09 20 20 20 28 6e 65 77 70 61 74 68 20 20 ).. (newpath
1260: 20 20 28 61 70 70 65 6e 64 20 74 72 69 6d 70 61 (append trimpa
1270: 74 68 20 28 6c 69 73 74 20 6e 6f 64 65 2d 74 69 th (list node-ti
1280: 74 6c 65 29 29 29 29 0a 20 20 20 20 20 20 28 69 tle)))). (i
1290: 66 20 28 3e 3d 20 63 75 72 72 6e 6f 64 65 20 6e f (>= currnode n
12a0: 6f 64 65 6e 75 6d 29 0a 09 20 20 6e 65 77 70 61 odenum).. newpa
12b0: 74 68 0a 09 20 20 28 6c 6f 6f 70 20 28 2b 20 63 th.. (loop (+ c
12c0: 75 72 72 6e 6f 64 65 20 31 29 0a 09 09 6e 65 77 urrnode 1)...new
12d0: 70 61 74 68 29 29 29 29 29 0a 0a 28 64 65 66 69 path)))))..(defi
12e0: 6e 65 20 28 74 72 65 65 3a 64 65 6c 65 74 65 2d ne (tree:delete-
12f0: 6e 6f 64 65 20 6f 62 6a 20 74 6f 70 20 6e 6f 64 node obj top nod
1300: 65 2d 70 61 74 68 29 20 3b 3b 20 6e 6f 64 65 2d e-path) ;; node-
1310: 70 61 74 68 20 69 73 20 61 20 6c 69 73 74 20 6f path is a list o
1320: 66 20 73 74 72 69 6e 67 73 0a 20 20 28 6c 65 74 f strings. (let
1330: 20 28 28 69 64 20 20 28 74 72 65 65 3a 66 69 6e ((id (tree:fin
1340: 64 2d 6e 6f 64 65 20 6f 62 6a 20 28 63 6f 6e 73 d-node obj (cons
1350: 20 74 6f 70 20 6e 6f 64 65 2d 70 61 74 68 29 29 top node-path))
1360: 29 29 0a 20 20 20 20 28 70 72 69 6e 74 20 22 46 )). (print "F
1370: 6f 75 6e 64 20 6e 6f 64 65 20 74 6f 20 72 65 6d ound node to rem
1380: 6f 76 65 20 22 20 69 64 20 22 20 66 6f 72 20 70 ove " id " for p
1390: 61 74 68 20 22 20 74 6f 70 20 22 20 22 20 6e 6f ath " top " " no
13a0: 64 65 2d 70 61 74 68 29 0a 20 20 20 20 28 69 75 de-path). (iu
13b0: 70 3a 61 74 74 72 69 62 75 74 65 2d 73 65 74 21 p:attribute-set!
13c0: 20 6f 62 6a 20 28 63 6f 6e 63 20 22 44 45 4c 4e obj (conc "DELN
13d0: 4f 44 45 22 20 69 64 29 20 22 53 45 4c 45 43 54 ODE" id) "SELECT
13e0: 45 44 22 29 29 29 0a 09 0a 23 7c 0a 0a 20 20 28 ED")))...#|.. (
13f0: 6c 65 74 2a 20 28 28 74 62 20 20 20 20 20 20 28 let* ((tb (
1400: 69 75 70 3a 74 72 65 65 62 6f 78 0a 20 20 20 20 iup:treebox.
1410: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 23 #
1420: 3a 76 61 6c 75 65 20 30 0a 20 20 20 20 20 20 20 :value 0.
1430: 20 20 20 20 20 20 20 20 20 20 20 20 23 3a 6e 61 #:na
1440: 6d 65 20 22 52 75 6e 73 22 0a 20 20 20 20 20 20 me "Runs".
1450: 20 20 20 20 20 20 20 20 20 20 20 20 20 23 3a 65 #:e
1460: 78 70 61 6e 64 20 22 59 45 53 22 0a 20 20 20 20 xpand "YES".
1470: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 23 #
1480: 3a 61 64 64 65 78 70 61 6e 64 65 64 20 22 4e 4f :addexpanded "NO
1490: 22 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ".
14a0: 20 20 20 20 20 23 3a 73 65 6c 65 63 74 69 6f 6e #:selection
14b0: 2d 63 62 0a 20 20 20 20 20 20 20 20 20 20 20 20 -cb.
14c0: 20 20 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 (lambda (
14d0: 6f 62 6a 20 69 64 20 73 74 61 74 65 29 0a 20 20 obj id state).
14e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
14f0: 20 20 20 3b 3b 20 28 70 72 69 6e 74 20 22 6f 62 ;; (print "ob
1500: 6a 3a 20 22 20 6f 62 6a 20 22 2c 20 69 64 3a 20 j: " obj ", id:
1510: 22 20 69 64 20 22 2c 20 73 74 61 74 65 3a 20 22 " id ", state: "
1520: 20 73 74 61 74 65 29 0a 20 20 20 20 20 20 20 20 state).
1530: 20 20 20 20 20 20 20 20 20 20 20 20 20 28 6c 65 (le
1540: 74 2a 20 28 28 72 75 6e 2d 70 61 74 68 20 28 74 t* ((run-path (t
1550: 72 65 65 3a 6e 6f 64 65 2d 3e 70 61 74 68 20 6f ree:node->path o
1560: 62 6a 20 69 64 29 29 0a 20 20 20 20 20 20 20 20 bj id)).
1570: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1580: 20 20 20 20 28 72 75 6e 2d 69 64 20 20 20 28 74 (run-id (t
1590: 72 65 65 2d 70 61 74 68 2d 3e 72 75 6e 2d 69 64 ree-path->run-id
15a0: 20 28 63 64 72 20 72 75 6e 2d 70 61 74 68 29 29 (cdr run-path))
15b0: 29 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 )).
15c0: 20 20 20 20 20 20 20 20 20 20 28 69 66 20 72 75 (if ru
15d0: 6e 2d 69 64 0a 20 20 20 20 20 20 20 20 20 20 20 n-id.
15e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
15f0: 28 62 65 67 69 6e 0a 20 20 20 20 20 20 20 20 20 (begin.
1600: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1610: 20 20 20 20 28 64 62 6f 61 72 64 3a 64 61 74 61 (dboard:data
1620: 2d 63 75 72 72 2d 72 75 6e 2d 69 64 2d 73 65 74 -curr-run-id-set
1630: 21 20 64 61 74 61 20 72 75 6e 2d 69 64 29 0a 20 ! data run-id).
1640: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1650: 20 20 20 20 20 20 20 20 20 20 20 20 28 64 61 73 (das
1660: 68 62 6f 61 72 64 3a 75 70 64 61 74 65 2d 72 75 hboard:update-ru
1670: 6e 2d 73 75 6d 6d 61 72 79 2d 74 61 62 29 29 29 n-summary-tab)))
1680: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
1690: 20 20 20 20 20 20 20 20 3b 3b 20 28 70 72 69 6e ;; (prin
16a0: 74 20 22 70 61 74 68 3a 20 22 20 28 74 72 65 65 t "path: " (tree
16b0: 3a 6e 6f 64 65 2d 3e 70 61 74 68 20 6f 62 6a 20 :node->path obj
16c0: 69 64 29 20 22 20 72 75 6e 2d 69 64 3a 20 22 20 id) " run-id: "
16d0: 72 75 6e 2d 69 64 29 0a 20 20 20 20 20 20 20 20 run-id).
16e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 29 )
16f0: 29 29 29 0a 7c 23 0a ))).|#.