define(`xSTREAMx',divnum)
divert(-1)
# @(#)Copyright (c), 1987, 1993 StatSci, Inc.  All rights reserved.
divert(xSTREAMx)
#tree.m		definitions for tree-walk logic
ifdef(`MAXLEV',,`define(`MAXLEV',20)')ifdef(`RESCAN',,`define(`RESCAN',NO)')dnl
ifdef(`ALONG',,`define(`ALONG',`')')ifdef(`DOWN',,`define(`DOWN',`')')dnl
ifdef(`UP',,`define(`UP',`')')dnl
define(`KLUDGE',43752)
define(`CURRENT',curent)
define(`PARENT',parent)
define(`NEXT',inext)
POINTER lastp(MAXLEV), up(MAXLEV),curent,inext,parent; integer level
define(`TREEWALK',`curent=$1; level=0
repeat{
	if(NAME(curent)!=USED & MODE(curent)==STR) {
		inext=VALUE(curent)
		DOWN
		level=level+1
		if(level>MAXLEV)FATAL(structure with more than MAXLEV levels)
		up(level)=curent; curent=FIRSTENT(inext)
		lastp(level)=LASTENT(inext)
		if(curent>lastp(level))goto KLUDGE	#null directories
		next
		}
	if(level>0) parent=up(level)
	if(NAME(curent)!=USED){ALONG}
# along or up
	curent=NEXTENT(curent)
KLUDGE	if(level<1) break
	while(curent>lastp(level)) {
		if(level<=1)break 2
		parent=up(level)
		UP
		ifelse(RESCAN,NO,`curent=NEXTENT(parent)',`curent=parent')
		level=level-1
		}
	}
undefine(`UP')undefine(`ALONG')undefine(`DOWN')undefine(`MAXLEV')dnl
undefine(`RESCAN')define(`KLUDGE',eval(KLUDGE+1))')
SCCS_ID(93749,`@(#)'tree.m 3.9 last edit 2/20/93 StatSci. From BASEFILE)
