#!/usr/bin/mumps #+ Copyright (C) 2022 by Kevin C. O'Kane #+ #+ Kevin C. O'Kane, Ph.D. #+ Professor Emeritus #+ Computer Science Department #+ University of Northern Iowa #+ Cedar Falls, IA 50614-0507 #+ kc.okane@gmail.com #+ https://threadsafebooks.com/ #+ https://www.cs.uni.edu/~okane/ #+ #+ This program is free software; you can redistribute it and/or modify #+ it under the terms of the GNU General Public License as published by #+ the Free Software Foundation; either version 2 of the License, or #+ (at your option) any later version. #+ #+ This program is distributed in the hope that it will be useful, #+ but WITHOUT ANY WARRANTY; without even the implied warranty of #+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #+ GNU General Public License for more details. #+ #+ You should have received a copy of the GNU General Public License #+ along with this program; if not, write to the Free Software #+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #+ # Jan 22, 2022 # "tree" is the global array reference to load. # It is supplied by the calling routine or # it defaults. if $data(tree)=0 set tree="^mesh" # It may be a top level array reference or # a node within the global array. # treeStore is assumed to be empty. # how many indices in tree? (depth) set depth=$qlength(tree) ; how many indices in next node? # if tree reference greater than top level (0), add each # node of original query to tree. set tmp="" if depth>0 do . set tmp=tree ; hold for future reference # if non-root ref is of the form: ^abc(1,2,3,4)... , # insert nodes ^a(1), ^a(2), ^a(3), ^a(4) ... into tree # initialize trx to "^abc(" . set trx=$piece(tree,"(",1)_"(" . for i=1:1:depth do .. if i>1 set trx=trx_","""_$qsubscript(tree,i)_"""" .. else set trx=trx_""""_$qsubscript(tree,i)_"""" .. set try=trx_")" .. set %=$z~gtk~tree~level~add(treeStore,i,try,@try,$qsubscript(try,i)) # starting at root node or the non-root node (after parents inserted), # insert nodes into tree at depth and add other row data. # quit when node depth matches original node depth. for do . set tree=$query(@tree) . if tree="" break . set i=$qlength(tree) . if i=depth if tmp'=tree break ; original level . set %=$z~gtk~tree~level~add(treeStore,i,tree,@tree,$qsubscript(tree,i))