Megatest

Hex Artifact Content
Login

Artifact 5b84d6f782e6e57a6997904dad5260cb918ee2a4:


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 75 73  ===========..(us
0390: 65 20 66 6f 72 6d 61 74 29 0a 28 72 65 71 75 69  e format).(requi
03a0: 72 65 2d 6c 69 62 72 61 72 79 20 69 75 70 29 0a  re-library iup).
03b0: 28 69 6d 70 6f 72 74 20 28 70 72 65 66 69 78 20  (import (prefix 
03c0: 69 75 70 20 69 75 70 3a 29 29 0a 28 75 73 65 20  iup iup:)).(use 
03d0: 63 61 6e 76 61 73 2d 64 72 61 77 29 0a 0a 28 75  canvas-draw)..(u
03e0: 73 65 20 73 71 6c 69 74 65 33 20 73 72 66 69 2d  se sqlite3 srfi-
03f0: 31 20 70 6f 73 69 78 20 72 65 67 65 78 20 72 65  1 posix regex re
0400: 67 65 78 2d 63 61 73 65 20 73 72 66 69 2d 36 39  gex-case srfi-69
0410: 29 0a 28 69 6d 70 6f 72 74 20 28 70 72 65 66 69  ).(import (prefi
0420: 78 20 73 71 6c 69 74 65 33 20 73 71 6c 69 74 65  x sqlite3 sqlite
0430: 33 3a 29 29 0a 0a 28 64 65 63 6c 61 72 65 20 28  3:))..(declare (
0440: 75 6e 69 74 20 74 72 65 65 29 29 0a 28 64 65 63  unit tree)).(dec
0450: 6c 61 72 65 20 28 75 73 65 73 20 6d 61 72 67 73  lare (uses margs
0460: 29 29 0a 28 64 65 63 6c 61 72 65 20 28 75 73 65  )).(declare (use
0470: 73 20 6c 61 75 6e 63 68 29 29 0a 3b 3b 20 28 64  s launch)).;; (d
0480: 65 63 6c 61 72 65 20 28 75 73 65 73 20 6d 65 67  eclare (uses meg
0490: 61 74 65 73 74 2d 76 65 72 73 69 6f 6e 29 29 0a  atest-version)).
04a0: 28 64 65 63 6c 61 72 65 20 28 75 73 65 73 20 67  (declare (uses g
04b0: 75 74 69 6c 73 29 29 0a 28 64 65 63 6c 61 72 65  utils)).(declare
04c0: 20 28 75 73 65 73 20 64 62 29 29 0a 28 64 65 63   (uses db)).(dec
04d0: 6c 61 72 65 20 28 75 73 65 73 20 73 65 72 76 65  lare (uses serve
04e0: 72 29 29 0a 3b 3b 20 28 64 65 63 6c 61 72 65 20  r)).;; (declare 
04f0: 28 75 73 65 73 20 73 79 6e 63 68 61 73 68 29 29  (uses synchash))
0500: 0a 28 64 65 63 6c 61 72 65 20 28 75 73 65 73 20  .(declare (uses 
0510: 64 63 6f 6d 6d 6f 6e 29 29 0a 0a 28 69 6e 63 6c  dcommon))..(incl
0520: 75 64 65 20 22 6d 65 67 61 74 65 73 74 2d 76 65  ude "megatest-ve
0530: 72 73 69 6f 6e 2e 73 63 6d 22 29 0a 28 69 6e 63  rsion.scm").(inc
0540: 6c 75 64 65 20 22 63 6f 6d 6d 6f 6e 5f 72 65 63  lude "common_rec
0550: 6f 72 64 73 2e 73 63 6d 22 29 0a 28 69 6e 63 6c  ords.scm").(incl
0560: 75 64 65 20 22 64 62 5f 72 65 63 6f 72 64 73 2e  ude "db_records.
0570: 73 63 6d 22 29 0a 28 69 6e 63 6c 75 64 65 20 22  scm").(include "
0580: 6b 65 79 5f 72 65 63 6f 72 64 73 2e 73 63 6d 22  key_records.scm"
0590: 29 0a 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  )..;;===========
05a0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
05b0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
05c0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
05d0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 3b 3b 20 54  ===========.;; T
05e0: 20 52 20 45 20 45 20 20 20 53 20 54 20 55 20 46   R E E   S T U F
05f0: 20 46 20 0a 3b 3b 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d   F .;;==========
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 3d 3d 3d  ================
0620: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d  ================
0630: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 0a 3b 3b  ============..;;
0640: 20 70 61 74 68 20 69 73 20 61 20 6c 69 73 74 20   path is a list 
0650: 6f 66 20 6e 6f 64 65 73 2c 20 65 61 63 68 20 74  of nodes, each t
0660: 68 65 20 63 68 69 6c 64 20 6f 66 20 74 68 65 20  he child of the 
0670: 70 72 65 76 69 6f 75 73 0a 3b 3b 20 74 68 69 73  previous.;; this
0680: 20 72 6f 75 74 69 6e 65 20 72 65 74 75 72 6e 73   routine returns
0690: 20 74 68 65 20 69 64 20 73 6f 20 61 6e 6f 74 68   the id so anoth
06a0: 65 72 20 6e 6f 64 65 20 63 61 6e 20 62 65 20 61  er node can be a
06b0: 64 64 65 64 0a 3b 3b 20 65 69 74 68 65 72 20 61  dded.;; either a
06c0: 73 20 61 20 6c 65 61 66 20 6f 72 20 61 73 20 61  s a leaf or as a
06d0: 20 62 72 61 6e 63 68 0a 3b 3b 0a 3b 3b 20 42 55   branch.;;.;; BU
06e0: 47 3a 20 54 68 69 73 20 6e 65 65 64 73 20 61 20  G: This needs a 
06f0: 73 74 6f 70 20 73 65 6e 73 6f 72 20 66 6f 72 20  stop sensor for 
0700: 77 68 65 6e 20 61 20 62 72 61 6e 63 68 20 69 73  when a branch is
0710: 20 65 78 68 61 75 73 74 65 64 0a 3b 3b 0a 28 64   exhausted.;;.(d
0720: 65 66 69 6e 65 20 28 74 72 65 65 3a 66 69 6e 64  efine (tree:find
0730: 2d 6e 6f 64 65 20 6f 62 6a 20 70 61 74 68 29 0a  -node obj path).
0740: 20 20 3b 3b 20 73 74 61 72 74 20 61 74 20 74 68    ;; start at th
0750: 65 20 62 61 73 65 20 6f 66 20 74 68 65 20 74 72  e base of the tr
0760: 65 65 0a 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20  ee.  (if (null? 
0770: 70 61 74 68 29 0a 20 20 20 20 20 20 23 66 20 3b  path).      #f ;
0780: 3b 20 6f 72 20 30 20 3f 3f 3f 3f 0a 20 20 20 20  ; or 0 ????.    
0790: 20 20 28 6c 65 74 20 6c 6f 6f 70 20 28 28 68 65    (let loop ((he
07a0: 64 20 20 20 20 20 20 28 63 61 72 20 70 61 74 68  d      (car path
07b0: 29 29 0a 09 09 20 28 74 61 6c 20 20 20 20 20 20  ))... (tal      
07c0: 28 63 64 72 20 70 61 74 68 29 29 0a 09 09 20 28  (cdr path))... (
07d0: 64 65 70 74 68 20 20 20 20 30 29 0a 09 09 20 28  depth    0)... (
07e0: 6e 6f 64 65 6e 75 6d 20 20 30 29 29 0a 09 3b 3b  nodenum  0))..;;
07f0: 20 6e 6f 64 65 73 20 69 6e 20 69 75 70 20 74 72   nodes in iup tr
0800: 65 65 20 61 72 65 20 31 30 30 25 20 73 65 71 75  ee are 100% sequ
0810: 65 6e 74 69 61 6c 20 73 6f 20 69 74 65 72 61 74  ential so iterat
0820: 65 20 6f 76 65 72 20 6e 6f 64 65 6e 75 6d 0a 09  e over nodenum..
0830: 28 69 66 20 28 69 75 70 3a 61 74 74 72 69 62 75  (if (iup:attribu
0840: 74 65 20 6f 62 6a 20 28 63 6f 6e 63 20 22 44 45  te obj (conc "DE
0850: 50 54 48 22 20 6e 6f 64 65 6e 75 6d 29 29 20 3b  PTH" nodenum)) ;
0860: 3b 20 65 6e 64 20 77 68 65 6e 20 6e 6f 20 6d 6f  ; end when no mo
0870: 72 65 20 6e 6f 64 65 73 0a 09 20 20 20 20 28 6c  re nodes..    (l
0880: 65 74 20 28 28 6e 6f 64 65 2d 64 65 70 74 68 20  et ((node-depth 
0890: 28 73 74 72 69 6e 67 2d 3e 6e 75 6d 62 65 72 20  (string->number 
08a0: 28 69 75 70 3a 61 74 74 72 69 62 75 74 65 20 6f  (iup:attribute o
08b0: 62 6a 20 28 63 6f 6e 63 20 22 44 45 50 54 48 22  bj (conc "DEPTH"
08c0: 20 6e 6f 64 65 6e 75 6d 29 29 29 29 0a 09 09 20   nodenum))))... 
08d0: 20 28 6e 6f 64 65 2d 74 69 74 6c 65 20 28 69 75   (node-title (iu
08e0: 70 3a 61 74 74 72 69 62 75 74 65 20 6f 62 6a 20  p:attribute obj 
08f0: 28 63 6f 6e 63 20 22 54 49 54 4c 45 22 20 6e 6f  (conc "TITLE" no
0900: 64 65 6e 75 6d 29 29 29 29 0a 09 20 20 20 20 20  denum))))..     
0910: 20 28 69 66 20 28 61 6e 64 20 28 65 71 75 61 6c   (if (and (equal
0920: 3f 20 64 65 70 74 68 20 6e 6f 64 65 2d 64 65 70  ? depth node-dep
0930: 74 68 29 0a 09 09 20 20 20 20 20 20 20 28 65 71  th)...       (eq
0940: 75 61 6c 3f 20 68 65 64 20 20 20 6e 6f 64 65 2d  ual? hed   node-
0950: 74 69 74 6c 65 29 29 20 3b 3b 20 79 65 70 2c 20  title)) ;; yep, 
0960: 74 68 69 73 20 69 73 20 74 68 65 20 6f 6e 65 21  this is the one!
0970: 0a 09 09 20 20 28 69 66 20 28 6e 75 6c 6c 3f 20  ...  (if (null? 
0980: 74 61 6c 29 20 3b 3b 20 65 6e 64 20 6f 66 20 74  tal) ;; end of t
0990: 68 65 20 6c 69 6e 65 0a 09 09 20 20 20 20 20 20  he line...      
09a0: 6e 6f 64 65 6e 75 6d 0a 09 09 20 20 20 20 20 20  nodenum...      
09b0: 28 6c 6f 6f 70 20 28 63 61 72 20 74 61 6c 29 28  (loop (car tal)(
09c0: 63 64 72 20 74 61 6c 29 28 2b 20 64 65 70 74 68  cdr tal)(+ depth
09d0: 20 31 29 28 2b 20 31 20 6e 6f 64 65 6e 75 6d 29   1)(+ 1 nodenum)
09e0: 29 29 0a 09 09 20 20 3b 3b 20 74 68 69 73 20 69  ))...  ;; this i
09f0: 73 20 74 68 65 20 63 61 73 65 20 77 68 65 72 65  s the case where
0a00: 20 77 65 20 66 6f 75 6e 64 20 70 61 72 74 20 6f   we found part o
0a10: 66 20 74 68 65 20 68 69 65 72 61 72 63 68 79 20  f the hierarchy 
0a20: 62 75 74 20 6e 6f 74 20 0a 09 09 20 20 3b 3b 20  but not ...  ;; 
0a30: 61 6c 6c 20 6f 66 20 69 74 2c 20 69 2e 65 2e 20  all of it, i.e. 
0a40: 74 68 65 20 6e 6f 64 65 2d 64 65 70 74 68 20 77  the node-depth w
0a50: 65 6e 74 20 66 72 6f 6d 20 64 65 65 70 20 74 6f  ent from deep to
0a60: 20 6c 65 73 73 20 64 65 65 70 0a 09 09 20 20 28   less deep...  (
0a70: 69 66 20 28 3e 20 64 65 70 74 68 20 6e 6f 64 65  if (> depth node
0a80: 2d 64 65 70 74 68 29 20 3b 3b 20 28 2b 20 31 20  -depth) ;; (+ 1 
0a90: 6e 6f 64 65 2d 64 65 70 74 68 29 29 0a 09 09 20  node-depth))... 
0aa0: 20 20 20 20 20 23 66 0a 09 09 20 20 20 20 20 20       #f...      
0ab0: 28 6c 6f 6f 70 20 68 65 64 20 74 61 6c 20 64 65  (loop hed tal de
0ac0: 70 74 68 20 28 2b 20 6e 6f 64 65 6e 75 6d 20 31  pth (+ nodenum 1
0ad0: 29 29 29 29 29 0a 09 20 20 20 20 23 66 29 29 29  )))))..    #f)))
0ae0: 29 0a 0a 3b 3b 20 74 6f 70 20 69 73 20 74 68 65  )..;; top is the
0af0: 20 74 6f 70 20 6e 6f 64 65 20 6e 61 6d 65 20 7a   top node name z
0b00: 65 72 6f 65 74 68 20 6e 6f 64 65 20 56 41 4c 55  eroeth node VALU
0b10: 45 3d 30 0a 28 64 65 66 69 6e 65 20 28 74 72 65  E=0.(define (tre
0b20: 65 3a 61 64 64 2d 6e 6f 64 65 20 6f 62 6a 20 74  e:add-node obj t
0b30: 6f 70 20 6e 6f 64 65 6c 73 74 20 23 21 6b 65 79  op nodelst #!key
0b40: 20 28 75 73 65 72 64 61 74 61 20 23 66 29 29 0a   (userdata #f)).
0b50: 20 20 28 6c 65 74 20 28 28 63 75 72 72 2d 74 6f    (let ((curr-to
0b60: 70 20 28 69 75 70 3a 61 74 74 72 69 62 75 74 65  p (iup:attribute
0b70: 20 6f 62 6a 20 22 54 49 54 4c 45 30 22 29 29 29   obj "TITLE0")))
0b80: 0a 20 20 20 20 28 69 66 20 28 6f 72 20 28 6e 6f  .    (if (or (no
0b90: 74 20 28 73 74 72 69 6e 67 3f 20 63 75 72 72 2d  t (string? curr-
0ba0: 74 6f 70 29 29 0a 09 20 20 20 20 28 73 74 72 69  top))..    (stri
0bb0: 6e 67 2d 6e 75 6c 6c 3f 20 63 75 72 72 2d 74 6f  ng-null? curr-to
0bc0: 70 29 0a 09 20 20 20 20 28 73 74 72 69 6e 67 2d  p)..    (string-
0bd0: 6d 61 74 63 68 20 22 5e 5c 5c 73 2a 24 22 20 63  match "^\\s*$" c
0be0: 75 72 72 2d 74 6f 70 29 29 0a 20 20 20 20 20 20  urr-top)).      
0bf0: 20 20 20 20 28 69 75 70 3a 61 74 74 72 69 62 75      (iup:attribu
0c00: 74 65 2d 73 65 74 21 20 6f 62 6a 20 22 41 44 44  te-set! obj "ADD
0c10: 42 52 41 4e 43 48 30 22 20 74 6f 70 29 29 0a 0a  BRANCH0" top))..
0c20: 0a 20 20 20 20 0a 20 20 20 20 28 63 6f 6e 64 0a  .    .    (cond.
0c30: 20 20 20 20 20 28 28 6e 6f 74 20 28 65 71 75 61       ((not (equa
0c40: 6c 3f 20 74 6f 70 20 28 69 75 70 3a 61 74 74 72  l? top (iup:attr
0c50: 69 62 75 74 65 20 6f 62 6a 20 22 54 49 54 4c 45  ibute obj "TITLE
0c60: 30 22 29 29 29 0a 20 20 20 20 20 20 28 70 72 69  0"))).      (pri
0c70: 6e 74 20 22 45 52 52 4f 52 3a 20 74 6f 70 20 6e  nt "ERROR: top n
0c80: 61 6d 65 20 22 20 74 6f 70 20 22 20 64 6f 65 73  ame " top " does
0c90: 6e 27 74 20 6d 61 74 63 68 20 22 20 28 69 75 70  n't match " (iup
0ca0: 3a 61 74 74 72 69 62 75 74 65 20 6f 62 6a 20 22  :attribute obj "
0cb0: 54 49 54 4c 45 30 22 29 29 29 0a 20 20 20 20 20  TITLE0"))).     
0cc0: 28 28 6e 75 6c 6c 3f 20 6e 6f 64 65 6c 73 74 29  ((null? nodelst)
0cd0: 29 0a 20 20 20 20 20 28 65 6c 73 65 0a 20 20 20  ).     (else.   
0ce0: 20 20 20 28 6c 65 74 20 6c 6f 6f 70 20 28 28 68     (let loop ((h
0cf0: 65 64 20 20 20 20 20 20 28 63 61 72 20 6e 6f 64  ed      (car nod
0d00: 65 6c 73 74 29 29 0a 09 09 20 28 74 61 6c 20 20  elst))... (tal  
0d10: 20 20 20 20 28 63 64 72 20 6e 6f 64 65 6c 73 74      (cdr nodelst
0d20: 29 29 0a 09 09 20 28 64 65 70 74 68 20 20 20 20  ))... (depth    
0d30: 31 29 0a 09 09 20 28 70 61 74 68 6c 20 20 20 20  1)... (pathl    
0d40: 28 6c 69 73 74 20 74 6f 70 29 29 29 0a 09 3b 3b  (list top)))..;;
0d50: 20 42 65 63 61 75 73 65 20 74 68 65 20 74 72 65   Because the tre
0d60: 65 20 64 69 61 6c 6f 67 20 63 68 61 6e 67 65 73  e dialog changes
0d70: 20 6e 6f 64 65 20 6e 75 6d 62 65 72 73 20 77 68   node numbers wh
0d80: 65 6e 0a 09 3b 3b 20 6e 6f 64 65 73 20 61 72 65  en..;; nodes are
0d90: 20 61 64 64 65 64 20 6f 72 20 72 65 6d 6f 76 65   added or remove
0da0: 64 20 77 65 20 6d 75 73 74 20 6c 6f 6f 6b 20 75  d we must look u
0db0: 70 20 6e 6f 64 65 73 0a 09 3b 3b 20 65 61 63 68  p nodes..;; each
0dc0: 20 61 6e 64 20 65 76 65 72 79 20 74 69 6d 65 2e   and every time.
0dd0: 20 30 20 69 73 20 74 68 65 20 74 6f 70 20 6e 6f   0 is the top no
0de0: 64 65 20 73 6f 20 64 65 66 61 75 6c 74 0a 09 3b  de so default..;
0df0: 3b 20 74 6f 20 74 68 61 74 2e 0a 09 28 6c 65 74  ; to that...(let
0e00: 2a 20 28 28 6e 65 77 70 61 74 68 20 20 20 20 28  * ((newpath    (
0e10: 61 70 70 65 6e 64 20 70 61 74 68 6c 20 28 6c 69  append pathl (li
0e20: 73 74 20 68 65 64 29 29 29 0a 09 20 20 20 20 20  st hed)))..     
0e30: 20 20 28 70 61 72 65 6e 74 6e 6f 64 65 20 28 74    (parentnode (t
0e40: 72 65 65 3a 66 69 6e 64 2d 6e 6f 64 65 20 6f 62  ree:find-node ob
0e50: 6a 20 70 61 74 68 6c 29 29 0a 09 20 20 20 20 20  j pathl))..     
0e60: 20 20 28 6e 6f 64 65 6e 75 6d 20 20 20 20 28 74    (nodenum    (t
0e70: 72 65 65 3a 66 69 6e 64 2d 6e 6f 64 65 20 6f 62  ree:find-node ob
0e80: 6a 20 6e 65 77 70 61 74 68 29 29 29 0a 09 20 20  j newpath)))..  
0e90: 3b 3b 20 41 64 64 20 74 68 65 20 62 72 61 6e 63  ;; Add the branc
0ea0: 68 20 75 6e 64 65 72 20 6c 61 73 74 6e 6f 64 65  h under lastnode
0eb0: 20 69 66 20 6e 6f 74 20 66 6f 75 6e 64 0a 09 20   if not found.. 
0ec0: 20 28 69 66 20 28 6e 6f 74 20 6e 6f 64 65 6e 75   (if (not nodenu
0ed0: 6d 29 0a 09 20 20 20 20 20 20 28 62 65 67 69 6e  m)..      (begin
0ee0: 0a 09 09 28 69 75 70 3a 61 74 74 72 69 62 75 74  ...(iup:attribut
0ef0: 65 2d 73 65 74 21 20 6f 62 6a 20 28 63 6f 6e 63  e-set! obj (conc
0f00: 20 22 41 44 44 42 52 41 4e 43 48 22 20 70 61 72   "ADDBRANCH" par
0f10: 65 6e 74 6e 6f 64 65 29 20 68 65 64 29 0a 09 09  entnode) hed)...
0f20: 3b 3b 20 45 52 52 4f 52 3f 20 41 44 44 49 4e 47  ;; ERROR? ADDING
0f30: 20 44 41 54 41 20 54 4f 20 50 41 52 45 4e 54 2c   DATA TO PARENT,
0f40: 20 44 4f 4e 54 20 57 45 20 57 41 4e 54 20 49 54   DONT WE WANT IT
0f50: 20 4f 4e 20 43 52 45 41 54 45 44 20 4e 4f 44 45   ON CREATED NODE
0f60: 3f 0a 09 09 28 69 66 20 75 73 65 72 64 61 74 61  ?...(if userdata
0f70: 0a 09 09 20 20 20 20 28 69 75 70 3a 61 74 74 72  ...    (iup:attr
0f80: 69 62 75 74 65 2d 73 65 74 21 20 6f 62 6a 20 28  ibute-set! obj (
0f90: 63 6f 6e 63 20 22 55 53 45 52 44 41 54 41 22 20  conc "USERDATA" 
0fa0: 20 20 70 61 72 65 6e 74 6e 6f 64 65 29 20 75 73    parentnode) us
0fb0: 65 72 64 61 74 61 29 29 0a 09 09 28 69 66 20 28  erdata))...(if (
0fc0: 6e 75 6c 6c 3f 20 74 61 6c 29 0a 09 09 20 20 20  null? tal)...   
0fd0: 20 23 74 0a 09 09 20 20 20 20 3b 3b 20 72 65 73   #t...    ;; res
0fe0: 65 74 20 74 6f 20 74 6f 70 0a 09 09 20 20 20 20  et to top...    
0ff0: 28 6c 6f 6f 70 20 28 63 61 72 20 6e 6f 64 65 6c  (loop (car nodel
1000: 73 74 29 28 63 64 72 20 6e 6f 64 65 6c 73 74 29  st)(cdr nodelst)
1010: 20 31 20 28 6c 69 73 74 20 74 6f 70 29 29 29 29   1 (list top))))
1020: 20 0a 09 20 20 20 20 20 20 28 69 66 20 28 6e 75   ..      (if (nu
1030: 6c 6c 3f 20 74 61 6c 29 20 3b 3b 20 69 66 20 6e  ll? tal) ;; if n
1040: 75 6c 6c 20 68 65 72 65 20 74 68 65 6e 20 74 68  ull here then th
1050: 69 73 20 70 61 74 68 20 68 61 73 20 61 6c 72 65  is path has alre
1060: 61 64 79 20 62 65 65 6e 20 61 64 64 65 64 0a 09  ady been added..
1070: 09 20 20 23 74 0a 09 09 20 20 28 6c 6f 6f 70 20  .  #t...  (loop 
1080: 28 63 61 72 20 74 61 6c 29 28 63 64 72 20 74 61  (car tal)(cdr ta
1090: 6c 29 28 2b 20 64 65 70 74 68 20 31 29 20 6e 65  l)(+ depth 1) ne
10a0: 77 70 61 74 68 29 29 29 29 29 29 29 29 29 0a 0a  wpath)))))))))..
10b0: 28 64 65 66 69 6e 65 20 28 74 72 65 65 3a 6e 6f  (define (tree:no
10c0: 64 65 2d 3e 70 61 74 68 20 6f 62 6a 20 6e 6f 64  de->path obj nod
10d0: 65 6e 75 6d 29 0a 20 20 28 6c 65 74 20 6c 6f 6f  enum).  (let loo
10e0: 70 20 28 28 63 75 72 72 6e 6f 64 65 20 30 29 0a  p ((currnode 0).
10f0: 09 20 20 20 20 20 28 70 61 74 68 20 20 20 20 20  .     (path     
1100: 27 28 29 29 29 0a 20 20 20 20 28 6c 65 74 2a 20  '())).    (let* 
1110: 28 28 6e 6f 64 65 2d 64 65 70 74 68 20 28 73 74  ((node-depth (st
1120: 72 69 6e 67 2d 3e 6e 75 6d 62 65 72 20 28 69 75  ring->number (iu
1130: 70 3a 61 74 74 72 69 62 75 74 65 20 6f 62 6a 20  p:attribute obj 
1140: 28 63 6f 6e 63 20 22 44 45 50 54 48 22 20 63 75  (conc "DEPTH" cu
1150: 72 72 6e 6f 64 65 29 29 29 29 0a 09 20 20 20 28  rrnode))))..   (
1160: 6e 6f 64 65 2d 74 69 74 6c 65 20 28 69 75 70 3a  node-title (iup:
1170: 61 74 74 72 69 62 75 74 65 20 6f 62 6a 20 28 63  attribute obj (c
1180: 6f 6e 63 20 22 54 49 54 4c 45 22 20 63 75 72 72  onc "TITLE" curr
1190: 6e 6f 64 65 29 29 29 0a 09 20 20 20 28 74 72 69  node)))..   (tri
11a0: 6d 70 61 74 68 20 20 20 28 69 66 20 28 61 6e 64  mpath   (if (and
11b0: 20 28 6e 6f 74 20 28 6e 75 6c 6c 3f 20 70 61 74   (not (null? pat
11c0: 68 29 29 0a 09 09 09 09 28 3e 20 28 6c 65 6e 67  h)).....(> (leng
11d0: 74 68 20 70 61 74 68 29 20 6e 6f 64 65 2d 64 65  th path) node-de
11e0: 70 74 68 29 29 0a 09 09 09 20 20 20 28 74 61 6b  pth))....   (tak
11f0: 65 20 70 61 74 68 20 6e 6f 64 65 2d 64 65 70 74  e path node-dept
1200: 68 29 0a 09 09 09 20 20 20 70 61 74 68 29 29 0a  h)....   path)).
1210: 09 20 20 20 28 6e 65 77 70 61 74 68 20 20 20 20  .   (newpath    
1220: 28 61 70 70 65 6e 64 20 74 72 69 6d 70 61 74 68  (append trimpath
1230: 20 28 6c 69 73 74 20 6e 6f 64 65 2d 74 69 74 6c   (list node-titl
1240: 65 29 29 29 29 0a 20 20 20 20 20 20 28 69 66 20  e)))).      (if 
1250: 28 3e 3d 20 63 75 72 72 6e 6f 64 65 20 6e 6f 64  (>= currnode nod
1260: 65 6e 75 6d 29 0a 09 20 20 6e 65 77 70 61 74 68  enum)..  newpath
1270: 0a 09 20 20 28 6c 6f 6f 70 20 28 2b 20 63 75 72  ..  (loop (+ cur
1280: 72 6e 6f 64 65 20 31 29 0a 09 09 6e 65 77 70 61  rnode 1)...newpa
1290: 74 68 29 29 29 29 29 0a 0a 28 64 65 66 69 6e 65  th)))))..(define
12a0: 20 28 74 72 65 65 3a 64 65 6c 65 74 65 2d 6e 6f   (tree:delete-no
12b0: 64 65 20 6f 62 6a 20 74 6f 70 20 6e 6f 64 65 2d  de obj top node-
12c0: 70 61 74 68 29 20 3b 3b 20 6e 6f 64 65 2d 70 61  path) ;; node-pa
12d0: 74 68 20 69 73 20 61 20 6c 69 73 74 20 6f 66 20  th is a list of 
12e0: 73 74 72 69 6e 67 73 0a 20 20 28 6c 65 74 20 28  strings.  (let (
12f0: 28 69 64 20 20 28 74 72 65 65 3a 66 69 6e 64 2d  (id  (tree:find-
1300: 6e 6f 64 65 20 6f 62 6a 20 28 63 6f 6e 73 20 74  node obj (cons t
1310: 6f 70 20 6e 6f 64 65 2d 70 61 74 68 29 29 29 29  op node-path))))
1320: 0a 20 20 20 20 28 70 72 69 6e 74 20 22 46 6f 75  .    (print "Fou
1330: 6e 64 20 6e 6f 64 65 20 74 6f 20 72 65 6d 6f 76  nd node to remov
1340: 65 20 22 20 69 64 20 22 20 66 6f 72 20 70 61 74  e " id " for pat
1350: 68 20 22 20 74 6f 70 20 22 20 22 20 6e 6f 64 65  h " top " " node
1360: 2d 70 61 74 68 29 0a 20 20 20 20 28 69 75 70 3a  -path).    (iup:
1370: 61 74 74 72 69 62 75 74 65 2d 73 65 74 21 20 6f  attribute-set! o
1380: 62 6a 20 28 63 6f 6e 63 20 22 44 45 4c 4e 4f 44  bj (conc "DELNOD
1390: 45 22 20 69 64 29 20 22 53 45 4c 45 43 54 45 44  E" id) "SELECTED
13a0: 22 29 29 29 0a 09 0a 23 7c 0a 0a 20 20 28 6c 65  ")))...#|..  (le
13b0: 74 2a 20 28 28 74 62 20 20 20 20 20 20 28 69 75  t* ((tb      (iu
13c0: 70 3a 74 72 65 65 62 6f 78 0a 20 20 20 20 20 20  p:treebox.      
13d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 23 3a 76               #:v
13e0: 61 6c 75 65 20 30 0a 20 20 20 20 20 20 20 20 20  alue 0.         
13f0: 20 20 20 20 20 20 20 20 20 20 23 3a 6e 61 6d 65            #:name
1400: 20 22 52 75 6e 73 22 0a 20 20 20 20 20 20 20 20   "Runs".        
1410: 20 20 20 20 20 20 20 20 20 20 20 23 3a 65 78 70             #:exp
1420: 61 6e 64 20 22 59 45 53 22 0a 20 20 20 20 20 20  and "YES".      
1430: 20 20 20 20 20 20 20 20 20 20 20 20 20 23 3a 61               #:a
1440: 64 64 65 78 70 61 6e 64 65 64 20 22 4e 4f 22 0a  ddexpanded "NO".
1450: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1460: 20 20 20 23 3a 73 65 6c 65 63 74 69 6f 6e 2d 63     #:selection-c
1470: 62 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20  b.              
1480: 20 20 20 20 20 28 6c 61 6d 62 64 61 20 28 6f 62       (lambda (ob
1490: 6a 20 69 64 20 73 74 61 74 65 29 0a 20 20 20 20  j id state).    
14a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
14b0: 20 3b 3b 20 28 70 72 69 6e 74 20 22 6f 62 6a 3a   ;; (print "obj:
14c0: 20 22 20 6f 62 6a 20 22 2c 20 69 64 3a 20 22 20   " obj ", id: " 
14d0: 69 64 20 22 2c 20 73 74 61 74 65 3a 20 22 20 73  id ", state: " s
14e0: 74 61 74 65 29 0a 20 20 20 20 20 20 20 20 20 20  tate).          
14f0: 20 20 20 20 20 20 20 20 20 20 20 28 6c 65 74 2a             (let*
1500: 20 28 28 72 75 6e 2d 70 61 74 68 20 28 74 72 65   ((run-path (tre
1510: 65 3a 6e 6f 64 65 2d 3e 70 61 74 68 20 6f 62 6a  e:node->path obj
1520: 20 69 64 29 29 0a 20 20 20 20 20 20 20 20 20 20   id)).          
1530: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1540: 20 20 28 72 75 6e 2d 69 64 20 20 20 28 74 72 65    (run-id   (tre
1550: 65 2d 70 61 74 68 2d 3e 72 75 6e 2d 69 64 20 28  e-path->run-id (
1560: 63 64 72 20 72 75 6e 2d 70 61 74 68 29 29 29 29  cdr run-path))))
1570: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
1580: 20 20 20 20 20 20 20 20 28 69 66 20 72 75 6e 2d          (if run-
1590: 69 64 0a 20 20 20 20 20 20 20 20 20 20 20 20 20  id.             
15a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 28 62                (b
15b0: 65 67 69 6e 0a 20 20 20 20 20 20 20 20 20 20 20  egin.           
15c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
15d0: 20 20 28 64 62 6f 61 72 64 3a 64 61 74 61 2d 63    (dboard:data-c
15e0: 75 72 72 2d 72 75 6e 2d 69 64 2d 73 65 74 21 20  urr-run-id-set! 
15f0: 64 61 74 61 20 72 75 6e 2d 69 64 29 0a 20 20 20  data run-id).   
1600: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1610: 20 20 20 20 20 20 20 20 20 20 28 64 61 73 68 62            (dashb
1620: 6f 61 72 64 3a 75 70 64 61 74 65 2d 72 75 6e 2d  oard:update-run-
1630: 73 75 6d 6d 61 72 79 2d 74 61 62 29 29 29 0a 20  summary-tab))). 
1640: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
1650: 20 20 20 20 20 20 3b 3b 20 28 70 72 69 6e 74 20        ;; (print 
1660: 22 70 61 74 68 3a 20 22 20 28 74 72 65 65 3a 6e  "path: " (tree:n
1670: 6f 64 65 2d 3e 70 61 74 68 20 6f 62 6a 20 69 64  ode->path obj id
1680: 29 20 22 20 72 75 6e 2d 69 64 3a 20 22 20 72 75  ) " run-id: " ru
1690: 6e 2d 69 64 29 0a 20 20 20 20 20 20 20 20 20 20  n-id).          
16a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 29 29 29               )))
16b0: 29 0a 7c 23 0a                                   ).|#.