| 1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
| 2 |
<HTML> |
| 3 |
<HEAD><TITLE>tree manual page - BLT Built-In Commands</TITLE><!--#include virtual="/man/maninc.html"--> |
| 4 |
<link rel="stylesheet" href="../docs.css" type="text/css" media="all"> |
| 5 |
</HEAD> |
| 6 |
<BODY> |
| 7 |
<DL> |
| 8 |
<DD><A HREF="tree.htm#M2" NAME="L3562">NAME</A> |
| 9 |
<DL><DD>tree - Create and manage tree data objects.</DD></DL> |
| 10 |
<DD><A HREF="tree.htm#M3" NAME="L3563">SYNOPSIS</A> |
| 11 |
<DL> |
| 12 |
</DL> |
| 13 |
<DD><A HREF="tree.htm#M4" NAME="L3564">DESCRIPTION</A> |
| 14 |
<DD><A HREF="tree.htm#M5" NAME="L3565">INTRODUCTION</A> |
| 15 |
<DD><A HREF="tree.htm#M6" NAME="L3566">SYNTAX</A> |
| 16 |
<DL class="syntax"> |
| 17 |
<DD><A HREF="tree.htm#M7" NAME="L3567"><B>tree create</B> ?<B>-fixed</B>? ?<B>-keyhash</B> <I>N</I>? ?<I>treeName</I>?</A> |
| 18 |
<DL class="syntax"> |
| 19 |
<DD><A HREF="tree.htm#M8" NAME="L3568"><B>-fixed</B></A> |
| 20 |
<DD><A HREF="tree.htm#M9" NAME="L3569"><B>-keyhash</B> <I>size</I></A> |
| 21 |
</DL> |
| 22 |
<DD><A HREF="tree.htm#M10" NAME="L3570"><B>tree destroy</B> <I>treeName</I>...</A> |
| 23 |
<DD><A HREF="tree.htm#M11" NAME="L3571"><B>tree names</B> ?<I>pattern</I>?</A> |
| 24 |
<DD><A HREF="tree.htm#M12" NAME="L3572"><B>tree op</B> <I>subcmd</I> ?<I>subsubcmd ...</I>? <I>treeName</I> ?<I>arg arg ...</I>?</A> |
| 25 |
</DL> |
| 26 |
<DD><A HREF="tree.htm#M13" NAME="L3573">NODE IDS AND TAGS</A> |
| 27 |
<DL class="node ids and tags"> |
| 28 |
<DD><A HREF="tree.htm#M14" NAME="L3574"><B>all</B></A> |
| 29 |
<DD><A HREF="tree.htm#M15" NAME="L3575"><B>nonroot</B></A> |
| 30 |
<DD><A HREF="tree.htm#M16" NAME="L3576"><B>rootchildren</B></A> |
| 31 |
<DD><A HREF="tree.htm#M17" NAME="L3577"><B>root</B></A> |
| 32 |
</DL> |
| 33 |
<DD><A HREF="tree.htm#M18" NAME="L3578">NODE MODIFIERS</A> |
| 34 |
<DL class="node modifiers"> |
| 35 |
<DD><A HREF="tree.htm#M19" NAME="L3579"><B>firstchild</B></A> |
| 36 |
<DD><A HREF="tree.htm#M20" NAME="L3580"><B>lastchild</B></A> |
| 37 |
<DD><A HREF="tree.htm#M21" NAME="L3581"><B>nextnode</B></A> |
| 38 |
<DD><A HREF="tree.htm#M22" NAME="L3582"><B>nextsibling</B></A> |
| 39 |
<DD><A HREF="tree.htm#M23" NAME="L3583"><B>parentnode</B></A> |
| 40 |
<DD><A HREF="tree.htm#M24" NAME="L3584"><B>prevnode</B></A> |
| 41 |
<DD><A HREF="tree.htm#M25" NAME="L3585"><B>prevsibling</B></A> |
| 42 |
<DD><A HREF="tree.htm#M26" NAME="L3586"><B>maxnode</B></A> |
| 43 |
<DD><A HREF="tree.htm#M27" NAME="L3587">"<I>label</I>"</A> |
| 44 |
<DD><A HREF="tree.htm#M28" NAME="L3588">'<I>label</I>'</A> |
| 45 |
</DL> |
| 46 |
<DD><A HREF="tree.htm#M29" NAME="L3589">TREE OPERATIONS</A> |
| 47 |
<DL class="tree operations"> |
| 48 |
<DD><A HREF="tree.htm#M30" NAME="L3590"><I>treeName</I> <B>ancestor</B> <I>node1</I> <I>node2</I></A> |
| 49 |
<DD><A HREF="tree.htm#M31" NAME="L3591"><I>treeName</I> <B>append</B> <I>node key</I> <I>string</I> ?<I>string ...</I>?</A> |
| 50 |
<DD><A HREF="tree.htm#M32" NAME="L3592"><I>treeName</I> <B>appendi</B> <I>tagnode key</I> <I>string</I> ?<I>string ...</I>?</A> |
| 51 |
<DD><A HREF="tree.htm#M33" NAME="L3593"><I>treeName</I> <B>apply</B> <I>node</I> ?<I>switches</I>?</A> |
| 52 |
<DL class="tree operations"> |
| 53 |
<DD><A HREF="tree.htm#M34" NAME="L3594"><B>-depth</B> <I>number</I></A> |
| 54 |
<DD><A HREF="tree.htm#M35" NAME="L3595"><B>-exact</B> <I>string</I></A> |
| 55 |
<DD><A HREF="tree.htm#M36" NAME="L3596"><B>-glob</B> <I>string</I></A> |
| 56 |
<DD><A HREF="tree.htm#M37" NAME="L3597"><B>-invert</B></A> |
| 57 |
<DD><A HREF="tree.htm#M38" NAME="L3598"><B>-isleaf</B></A> |
| 58 |
<DD><A HREF="tree.htm#M39" NAME="L3599"><B>-istree</B></A> |
| 59 |
<DD><A HREF="tree.htm#M40" NAME="L3600"><B>-key</B> <I>key</I></A> |
| 60 |
<DD><A HREF="tree.htm#M41" NAME="L3601"><B>-keyglob</B> <I>key</I></A> |
| 61 |
<DD><A HREF="tree.htm#M42" NAME="L3602"><B>-keyregexp</B> <I>key</I></A> |
| 62 |
<DD><A HREF="tree.htm#M43" NAME="L3603"><B>-keyexact</B> <I>key</I></A> |
| 63 |
<DD><A HREF="tree.htm#M44" NAME="L3604"><B>-nocase</B></A> |
| 64 |
<DD><A HREF="tree.htm#M45" NAME="L3605"><B>-precommand</B> <I>command</I></A> |
| 65 |
<DD><A HREF="tree.htm#M46" NAME="L3606"><B>-postcommand</B> <I>command</I></A> |
| 66 |
<DD><A HREF="tree.htm#M47" NAME="L3607"><B>-regexp</B> <I>string</I></A> |
| 67 |
<DD><A HREF="tree.htm#M48" NAME="L3608"><B>-tag</B> <I>string</I></A> |
| 68 |
<DD><A HREF="tree.htm#M49" NAME="L3609"><B>-usepath</B></A> |
| 69 |
</DL> |
| 70 |
<DD><A HREF="tree.htm#M50" NAME="L3610"><I>treeName</I> <B>children</B> ?<B>-labels</B>? <I>node</I> ?<I>first</I>? ?<I>last</I>?</A> |
| 71 |
<DD><A HREF="tree.htm#M51" NAME="L3611"><I>treeName</I> <B>copy</B> <I>srcNode</I> ?<I>destTree</I>? <I>parentNode</I> ?<I>switches</I>?</A> |
| 72 |
<DL class="tree operations"> |
| 73 |
<DD><A HREF="tree.htm#M52" NAME="L3612"><B>-label</B> <I>string</I></A> |
| 74 |
<DD><A HREF="tree.htm#M53" NAME="L3613"><B>-overwrite</B></A> |
| 75 |
<DD><A HREF="tree.htm#M54" NAME="L3614"><B>-recurse</B></A> |
| 76 |
<DD><A HREF="tree.htm#M55" NAME="L3615"><B>-reverse</B></A> |
| 77 |
<DD><A HREF="tree.htm#M56" NAME="L3616"><B>-tags</B></A> |
| 78 |
</DL> |
| 79 |
<DD><A HREF="tree.htm#M57" NAME="L3617"><I>treeName</I> <B>create</B> ?<I>switches</I>?</A> |
| 80 |
<DL class="tree operations"> |
| 81 |
<DD><A HREF="tree.htm#M58" NAME="L3618"><B>-at</B> <I>number</I></A> |
| 82 |
<DD><A HREF="tree.htm#M59" NAME="L3619"><B>-fixed</B></A> |
| 83 |
<DD><A HREF="tree.htm#M60" NAME="L3620"><B>-data</B> <I>list</I></A> |
| 84 |
<DD><A HREF="tree.htm#M61" NAME="L3621"><B>-labelstart</B> <I>number</I></A> |
| 85 |
<DD><A HREF="tree.htm#M62" NAME="L3622"><B>-nodes</B> <I>list</I></A> |
| 86 |
<DD><A HREF="tree.htm#M63" NAME="L3623"><B>-num</B> <I>number</I></A> |
| 87 |
<DD><A HREF="tree.htm#M64" NAME="L3624"><B>-offset</B> <I>number</I></A> |
| 88 |
<DD><A HREF="tree.htm#M65" NAME="L3625"><B>-parent</B> <I>node</I></A> |
| 89 |
<DD><A HREF="tree.htm#M66" NAME="L3626"><B>-path</B> <I>pathList</I></A> |
| 90 |
<DD><A HREF="tree.htm#M67" NAME="L3627"><B>-prefix</B> <I>str</I></A> |
| 91 |
<DD><A HREF="tree.htm#M68" NAME="L3628"><B>-start</B> <I>number</I></A> |
| 92 |
<DD><A HREF="tree.htm#M69" NAME="L3629"><B>-tags</B> <I>tagList</I></A> |
| 93 |
</DL> |
| 94 |
<DD><A HREF="tree.htm#M70" NAME="L3630"><I>treeName</I> <B>degree</B> <I>node</I></A> |
| 95 |
<DD><A HREF="tree.htm#M71" NAME="L3631"><I>treeName</I> <B>delete</B> <I>node</I>...</A> |
| 96 |
<DD><A HREF="tree.htm#M72" NAME="L3632"><I>treeName</I> <B>depth</B> <I>node</I></A> |
| 97 |
<DD><A HREF="tree.htm#M73" NAME="L3633"><I>treeName</I> <B>dump</B> <I>node</I> ?<I>switches</I>?</A> |
| 98 |
<DL class="tree operations"> |
| 99 |
<DD><A HREF="tree.htm#M74" NAME="L3634"><B>-channel </B><I>chan</I></A> |
| 100 |
<DD><A HREF="tree.htm#M75" NAME="L3635"><B>-file </B><I>fileName</I></A> |
| 101 |
<DD><A HREF="tree.htm#M76" NAME="L3636"><B>-keys </B><I>list</I></A> |
| 102 |
<DD><A HREF="tree.htm#M77" NAME="L3637"><B>-skipkeys </B><I>list</I></A> |
| 103 |
<DD><A HREF="tree.htm#M78" NAME="L3638"><B>-tag </B><I>pattern</I></A> |
| 104 |
<DD><A HREF="tree.htm#M79" NAME="L3639"><B>-skiptag </B><I>pattern</I></A> |
| 105 |
<DD><A HREF="tree.htm#M80" NAME="L3640"><B>-notags</B></A> |
| 106 |
<DD><A HREF="tree.htm#M81" NAME="L3641"><B>-nopath</B></A> |
| 107 |
</DL> |
| 108 |
<DD><A HREF="tree.htm#M82" NAME="L3642"><I>treeName</I> <B>exists</B> <I>node</I> ?<I>key</I>?</A> |
| 109 |
<DD><A HREF="tree.htm#M83" NAME="L3643"><I>treeName</I> <B>find</B> ?<I>switches</I>?</A> |
| 110 |
<DL class="tree operations"> |
| 111 |
<DD><A HREF="tree.htm#M84" NAME="L3644"><B>-addtag</B> <I>string</I></A> |
| 112 |
<DD><A HREF="tree.htm#M85" NAME="L3645"><B>-command</B> <I>command</I></A> |
| 113 |
<DD><A HREF="tree.htm#M86" NAME="L3646"><B>-count</B></A> |
| 114 |
<DD><A HREF="tree.htm#M87" NAME="L3647"><B>-depth</B> <I>number</I></A> |
| 115 |
<DD><A HREF="tree.htm#M88" NAME="L3648"><B>-exact</B></A> |
| 116 |
<DD><A HREF="tree.htm#M89" NAME="L3649"><B>-exec</B> <I>script</I></A> |
| 117 |
<DL class="tree operations"> |
| 118 |
<DD><A HREF="tree.htm#M90" NAME="L3650"><B>%#</B></A> |
| 119 |
<DD><A HREF="tree.htm#M91" NAME="L3651"><B>%W</B></A> |
| 120 |
<DD><A HREF="tree.htm#M92" NAME="L3652"><B>%p</B></A> |
| 121 |
<DD><A HREF="tree.htm#M93" NAME="L3653"><B>%P</B></A> |
| 122 |
<DD><A HREF="tree.htm#M94" NAME="L3654"><B>%R</B></A> |
| 123 |
<DD><A HREF="tree.htm#M95" NAME="L3655"><B>%r</B></A> |
| 124 |
<DD><A HREF="tree.htm#M96" NAME="L3656"><B>%T</B></A> |
| 125 |
<DD><A HREF="tree.htm#M97" NAME="L3657"><B>%V</B></A> |
| 126 |
<DD><A HREF="tree.htm#M98" NAME="L3658"><B>%D</B></A> |
| 127 |
<DD><A HREF="tree.htm#M99" NAME="L3659"><B>%%</B></A> |
| 128 |
</DL> |
| 129 |
<DD><A HREF="tree.htm#M100" NAME="L3660"><B>-glob</B></A> |
| 130 |
<DD><A HREF="tree.htm#M101" NAME="L3661"><B>-isarray</B></A> |
| 131 |
<DD><A HREF="tree.htm#M102" NAME="L3662"><B>-invert</B></A> |
| 132 |
<DD><A HREF="tree.htm#M103" NAME="L3663"><B>-isfixed</B></A> |
| 133 |
<DD><A HREF="tree.htm#M104" NAME="L3664"><B>-isleaf</B></A> |
| 134 |
<DD><A HREF="tree.htm#M105" NAME="L3665"><B>-isnotfixed</B></A> |
| 135 |
<DD><A HREF="tree.htm#M106" NAME="L3666"><B>-istree</B></A> |
| 136 |
<DD><A HREF="tree.htm#M107" NAME="L3667"><B>-keycount</B> <I>num</I></A> |
| 137 |
<DD><A HREF="tree.htm#M108" NAME="L3668"><B>-key</B> <I>key</I></A> |
| 138 |
<DD><A HREF="tree.htm#M109" NAME="L3669"><B>-keyglob</B> <I>key</I></A> |
| 139 |
<DD><A HREF="tree.htm#M110" NAME="L3670"><B>-keyregexp</B> <I>key</I></A> |
| 140 |
<DD><A HREF="tree.htm#M111" NAME="L3671"><B>-keyexact</B> <I>key</I></A> |
| 141 |
<DD><A HREF="tree.htm#M112" NAME="L3672"><B>-limit</B> <I>number</I></A> |
| 142 |
<DD><A HREF="tree.htm#M113" NAME="L3673"><B>-maxdepth</B> <I>number</I></A> |
| 143 |
<DD><A HREF="tree.htm#M114" NAME="L3674"><B>-mindepth</B> <I>number</I></A> |
| 144 |
<DD><A HREF="tree.htm#M115" NAME="L3675"><B>-name</B> <I>string</I></A> |
| 145 |
<DD><A HREF="tree.htm#M116" NAME="L3676"><B>-nocase</B></A> |
| 146 |
<DD><A HREF="tree.htm#M117" NAME="L3677"><B>-nodes </B><I>tagnode</I></A> |
| 147 |
<DD><A HREF="tree.htm#M118" NAME="L3678"><B>-notop</B></A> |
| 148 |
<DD><A HREF="tree.htm#M119" NAME="L3679"><B>-order</B> <I>string</I></A> |
| 149 |
<DL class="tree operations"> |
| 150 |
<DD><A HREF="tree.htm#M120" NAME="L3680"><B>breadthfirst</B></A> |
| 151 |
<DD><A HREF="tree.htm#M121" NAME="L3681"><B>inorder</B></A> |
| 152 |
<DD><A HREF="tree.htm#M122" NAME="L3682"><B>postorder</B></A> |
| 153 |
<DD><A HREF="tree.htm#M123" NAME="L3683"><B>preorder</B></A> |
| 154 |
</DL> |
| 155 |
<DD><A HREF="tree.htm#M124" NAME="L3684"><B>-usepath</B></A> |
| 156 |
<DD><A HREF="tree.htm#M125" NAME="L3685"><B>-regexp</B></A> |
| 157 |
<DD><A HREF="tree.htm#M126" NAME="L3686"><B>-reldepth</B></A> |
| 158 |
<DD><A HREF="tree.htm#M127" NAME="L3687"><B>-return </B><I>key</I></A> |
| 159 |
<DD><A HREF="tree.htm#M128" NAME="L3688"><B>-top </B><I>node</I></A> |
| 160 |
<DD><A HREF="tree.htm#M129" NAME="L3689"><B>-var </B><I>variable</I></A> |
| 161 |
<DD><A HREF="tree.htm#M130" NAME="L3690"><B>-withtag</B> <I>string</I></A> |
| 162 |
<DD><A HREF="tree.htm#M131" NAME="L3691"><B>-withouttag</B> <I>string</I></A> |
| 163 |
</DL> |
| 164 |
<DD><A HREF="tree.htm#M132" NAME="L3692"><I>treeName</I> <B>findchild</B> <I>node</I> <I>label</I></A> |
| 165 |
<DD><A HREF="tree.htm#M133" NAME="L3693"><I>treeName</I> <B>firstchild</B> <I>node</I></A> |
| 166 |
<DD><A HREF="tree.htm#M134" NAME="L3694"><I>treeName</I> <B>fixed</B> <I>node</I> ?<I>isfixed</I>?</A> |
| 167 |
<DD><A HREF="tree.htm#M135" NAME="L3695"><I>treeName</I> <B>foreach</B> <I>var tagnode script</I></A> |
| 168 |
<DD><A HREF="tree.htm#M136" NAME="L3696"><I>treeName</I> <B>get</B> <I>node</I> ?<I>key</I>? ?<I>defaultValue</I>?</A> |
| 169 |
<DD><A HREF="tree.htm#M137" NAME="L3697"><I>treeName</I> <B>incr</B> <I>node key</I> ?<I>amount</I>?</A> |
| 170 |
<DD><A HREF="tree.htm#M138" NAME="L3698"><I>treeName</I> <B>incri</B> <I>tagnode key</I> ?<I>amount</I>?</A> |
| 171 |
<DD><A HREF="tree.htm#M139" NAME="L3699"><I>treeName</I> <B>index</B> <I>node</I></A> |
| 172 |
<DD><A HREF="tree.htm#M140" NAME="L3700"><I>treeName</I> <B>insert</B> <I>parent</I> ?<I>switches</I>?</A> |
| 173 |
<DL class="tree operations"> |
| 174 |
<DD><A HREF="tree.htm#M141" NAME="L3701"><B>-after</B> <I>child</I></A> |
| 175 |
<DD><A HREF="tree.htm#M142" NAME="L3702"><B>-at</B> <I>number</I></A> |
| 176 |
<DD><A HREF="tree.htm#M143" NAME="L3703"><B>-before</B> <I>child</I></A> |
| 177 |
<DD><A HREF="tree.htm#M144" NAME="L3704"><B>-data</B> <I>dataList</I></A> |
| 178 |
<DD><A HREF="tree.htm#M145" NAME="L3705"><B>-fixed</B> <I>bool</I></A> |
| 179 |
<DD><A HREF="tree.htm#M146" NAME="L3706"><B>-label</B> <I>string</I></A> |
| 180 |
<DD><A HREF="tree.htm#M147" NAME="L3707"><B>-names</B> <I>nameList</I></A> |
| 181 |
<DD><A HREF="tree.htm#M148" NAME="L3708"><B>-node</B> <I>id</I></A> |
| 182 |
<DD><A HREF="tree.htm#M149" NAME="L3709"><B>-pretags</B> <I>tagList</I></A> |
| 183 |
<DD><A HREF="tree.htm#M150" NAME="L3710"><B>-tags</B> <I>tagList</I></A> |
| 184 |
<DD><A HREF="tree.htm#M151" NAME="L3711"><B>-values</B> <I>valueList</I></A> |
| 185 |
</DL> |
| 186 |
<DD><A HREF="tree.htm#M152" NAME="L3712"><I>treeName</I> <B>is</B> <I>property</I> <I>args</I></A> |
| 187 |
<DL class="tree operations"> |
| 188 |
<DD><A HREF="tree.htm#M153" NAME="L3713"><B>ancestor</B> <I>node1</I> <I>node2</I></A> |
| 189 |
<DD><A HREF="tree.htm#M154" NAME="L3714"><B>before</B> <I>node1</I> <I>node2</I></A> |
| 190 |
<DD><A HREF="tree.htm#M155" NAME="L3715"><B>leaf</B> <I>node</I></A> |
| 191 |
<DD><A HREF="tree.htm#M156" NAME="L3716"><B>root</B> <I>node</I></A> |
| 192 |
</DL> |
| 193 |
<DD><A HREF="tree.htm#M157" NAME="L3717"><I>treeName</I> <B>ismodified</B> ?<I>nodeOrTag</I>? ?<I>isflag</I>?</A> |
| 194 |
<DD><A HREF="tree.htm#M158" NAME="L3718"><I>treeName</I> <B>keys</B> <I>node</I> ?<I>tagnode ...</I>?</A> |
| 195 |
<DD><A HREF="tree.htm#M159" NAME="L3719"><I>treeName</I> <B>label</B> <I>node</I> ?<I>newLabel</I>?</A> |
| 196 |
<DD><A HREF="tree.htm#M160" NAME="L3720"><I>treeName</I> <B>lappend</B> <I>node key</I> <I>value</I> ?<I>value ...</I>?</A> |
| 197 |
<DD><A HREF="tree.htm#M161" NAME="L3721"><I>treeName</I> <B>lappendi</B> <I>tagnode key</I> <I>value</I> ?<I>value ...</I>?</A> |
| 198 |
<DD><A HREF="tree.htm#M162" NAME="L3722"><I>treeName</I> <B>lastchild</B> <I>node</I></A> |
| 199 |
<DD><A HREF="tree.htm#M163" NAME="L3723"><I>treeName</I> <B>modify</B> <I>tagnode</I> <I>key value</I> ?<I>key value</I>...?</A> |
| 200 |
<DD><A HREF="tree.htm#M164" NAME="L3724"><I>treeName</I> <B>move</B> <I>node</I> <I>newParent</I> ?<I>switches</I>?</A> |
| 201 |
<DL class="tree operations"> |
| 202 |
<DD><A HREF="tree.htm#M165" NAME="L3725"><B>-after</B> <I>child</I></A> |
| 203 |
<DD><A HREF="tree.htm#M166" NAME="L3726"><B>-at</B> <I>number</I></A> |
| 204 |
<DD><A HREF="tree.htm#M167" NAME="L3727"><B>-before</B> <I>child</I></A> |
| 205 |
</DL> |
| 206 |
<DD><A HREF="tree.htm#M168" NAME="L3728"><I>treeName</I> <B>names</B> <I>node</I> ?<I>key</I>?</A> |
| 207 |
<DD><A HREF="tree.htm#M169" NAME="L3729"><I>treeName</I> <B>next</B> <I>node</I></A> |
| 208 |
<DD><A HREF="tree.htm#M170" NAME="L3730"><I>treeName</I> <B>nextsibling</B> <I>node</I></A> |
| 209 |
<DD><A HREF="tree.htm#M171" NAME="L3731"><I>treeName</I> <B>nodeseq</B> ?<I>start</I>?</A> |
| 210 |
<DD><A HREF="tree.htm#M172" NAME="L3732"><I>treeName</I> <B>notify</B> <I>args</I></A> |
| 211 |
<DD><A HREF="tree.htm#M173" NAME="L3733"><I>treeName</I> <B>oldvalue</B> ?<I>newvalue</I>?</A> |
| 212 |
<DD><A HREF="tree.htm#M174" NAME="L3734"><I>treeName</I> <B>parent</B> <I>node</I></A> |
| 213 |
<DD><A HREF="tree.htm#M175" NAME="L3735"><I>treeName</I> <B>path</B> <I>node</I> ?<I>delim</I>? ?<I>prefix</I>?</A> |
| 214 |
<DD><A HREF="tree.htm#M176" NAME="L3736"><I>treeName</I> <B>position</B> ?<B>-sort</B>? ?<B>-format</B> <I>ftype</I>? <I>node</I> ?<I>node</I> ...?</A> |
| 215 |
<DD><A HREF="tree.htm#M177" NAME="L3737"><I>treeName</I> <B>previous</B> <I>node</I></A> |
| 216 |
<DD><A HREF="tree.htm#M178" NAME="L3738"><I>treeName</I> <B>prevsibling</B> <I>node</I></A> |
| 217 |
<DD><A HREF="tree.htm#M179" NAME="L3739"><I>treeName</I> <B>restore</B> <I>node</I> <I>switches</I></A> |
| 218 |
<DL class="tree operations"> |
| 219 |
<DD><A HREF="tree.htm#M180" NAME="L3740"><B>-addtags</B></A> |
| 220 |
<DD><A HREF="tree.htm#M181" NAME="L3741"><B>-channel </B><I>chan</I></A> |
| 221 |
<DD><A HREF="tree.htm#M182" NAME="L3742"><B>-data </B><I>string</I></A> |
| 222 |
<DD><A HREF="tree.htm#M183" NAME="L3743"><B>-file </B><I>fileName</I></A> |
| 223 |
<DD><A HREF="tree.htm#M184" NAME="L3744"><B>-keys </B><I>list</I></A> |
| 224 |
<DD><A HREF="tree.htm#M185" NAME="L3745"><B>-skipkeys </B><I>list</I></A> |
| 225 |
<DD><A HREF="tree.htm#M186" NAME="L3746"><B>-tag </B><I>pattern</I></A> |
| 226 |
<DD><A HREF="tree.htm#M187" NAME="L3747"><B>-skiptag </B><I>pattern</I></A> |
| 227 |
<DD><A HREF="tree.htm#M188" NAME="L3748"><B>-notags</B></A> |
| 228 |
<DD><A HREF="tree.htm#M189" NAME="L3749"><B>-overwrite</B></A> |
| 229 |
</DL> |
| 230 |
<DD><A HREF="tree.htm#M190" NAME="L3750"><I>treeName</I> <B>root</B> ?<I>node</I>?</A> |
| 231 |
<DD><A HREF="tree.htm#M191" NAME="L3751"><I>treeName</I> <B>set</B> <I>tagnode</I> <I>key value</I> ?<I>key value</I>...?</A> |
| 232 |
<DD><A HREF="tree.htm#M192" NAME="L3752"><I>treeName</I> <B>size</B> <I>node</I></A> |
| 233 |
<DD><A HREF="tree.htm#M193" NAME="L3753"><I>treeName</I> <B>sort</B> <I>node</I> ?<I>switches</I>?</A> |
| 234 |
<DL class="tree operations"> |
| 235 |
<DD><A HREF="tree.htm#M194" NAME="L3754"><B>-ascii</B></A> |
| 236 |
<DD><A HREF="tree.htm#M195" NAME="L3755"><B>-command</B> <I>string</I></A> |
| 237 |
<DD><A HREF="tree.htm#M196" NAME="L3756"><B>-decreasing</B></A> |
| 238 |
<DD><A HREF="tree.htm#M197" NAME="L3757"><B>-dictionary</B></A> |
| 239 |
<DD><A HREF="tree.htm#M198" NAME="L3758"><B>-integer</B></A> |
| 240 |
<DD><A HREF="tree.htm#M199" NAME="L3759"><B>-key</B> <I>string</I></A> |
| 241 |
<DD><A HREF="tree.htm#M200" NAME="L3760"><B>-real</B></A> |
| 242 |
<DD><A HREF="tree.htm#M201" NAME="L3761"><B>-recurse</B></A> |
| 243 |
<DD><A HREF="tree.htm#M202" NAME="L3762"><B>-reorder</B></A> |
| 244 |
<DD><A HREF="tree.htm#M203" NAME="L3763"><B>-usepath</B></A> |
| 245 |
</DL> |
| 246 |
<DD><A HREF="tree.htm#M204" NAME="L3764"><I>treeName</I> <B>sqlload</B> ?<I>switches</I>? <I>dbhfile</I> <I>sqlstmt</I></A> |
| 247 |
<DL class="tree operations"> |
| 248 |
<DD><A HREF="tree.htm#M205" NAME="L3765"><B>-addtags </B><I>taglist</I></A> |
| 249 |
<DD><A HREF="tree.htm#M206" NAME="L3766"><B>-at </B><I>num</I></A> |
| 250 |
<DD><A HREF="tree.htm#M207" NAME="L3767"><B>-fixed</B></A> |
| 251 |
<DD><A HREF="tree.htm#M208" NAME="L3768"><B>-key </B><I>name</I></A> |
| 252 |
<DD><A HREF="tree.htm#M209" NAME="L3769"><B>-labelcol </B><I>column</I></A> |
| 253 |
<DD><A HREF="tree.htm#M210" NAME="L3770"><B>-maprowid </B><I>num</I></A> |
| 254 |
<DD><A HREF="tree.htm#M211" NAME="L3771"><B>-max </B><I>num</I></A> |
| 255 |
<DD><A HREF="tree.htm#M212" NAME="L3772"><B>-nullvalue </B><I>string</I></A> |
| 256 |
<DD><A HREF="tree.htm#M213" NAME="L3773"><B>-parent </B><I>string</I></A> |
| 257 |
<DD><A HREF="tree.htm#M214" NAME="L3774"><B>-pathcol </B><I>column</I></A> |
| 258 |
<DD><A HREF="tree.htm#M215" NAME="L3775"><B>-skipcols </B><I>columns</I></A> |
| 259 |
<DD><A HREF="tree.htm#M216" NAME="L3776"><B>-tagcol </B><I>column</I></A> |
| 260 |
<DD><A HREF="tree.htm#M217" NAME="L3777"><B>-treecols </B><I>columns</I></A> |
| 261 |
</DL> |
| 262 |
<DD><A HREF="tree.htm#M218" NAME="L3778"><I>treeName</I> <B>sum</B> ?<I>switches</I>? <I>tagnode key</I> ?<I>key ...</I>?</A> |
| 263 |
<DL class="tree operations"> |
| 264 |
<DD><A HREF="tree.htm#M219" NAME="L3779"><B>-diff</B><I> value</I></A> |
| 265 |
<DD><A HREF="tree.htm#M220" NAME="L3780"><B>-force</B></A> |
| 266 |
<DD><A HREF="tree.htm#M221" NAME="L3781"><B>-int</B></A> |
| 267 |
<DD><A HREF="tree.htm#M222" NAME="L3782"><B>-runtotal </B><I>key</I></A> |
| 268 |
<DD><A HREF="tree.htm#M223" NAME="L3783"><B>-start </B><I>num</I></A> |
| 269 |
</DL> |
| 270 |
<DD><A HREF="tree.htm#M224" NAME="L3784"><I>treeName</I> <B>supdate</B> <I>node</I> <I>key value</I> ?<I>key value</I>...?</A> |
| 271 |
<DD><A HREF="tree.htm#M225" NAME="L3785"><I>treeName</I> <B>tag</B> <I>args</I></A> |
| 272 |
<DD><A HREF="tree.htm#M226" NAME="L3786"><I>treeName</I> <B>trace</B> <I>args</I></A> |
| 273 |
<DD><A HREF="tree.htm#M227" NAME="L3787"><I>treeName</I> <B>type</B> <I>node</I> <I>key</I></A> |
| 274 |
<DD><A HREF="tree.htm#M228" NAME="L3788"><I>treeName</I> <B>update</B> <I>node</I> <I>key value</I> ?<I>key value</I>...?</A> |
| 275 |
<DD><A HREF="tree.htm#M229" NAME="L3789"><I>treeName</I> <B>unset</B> <I>node</I> <I>key</I>...</A> |
| 276 |
<DD><A HREF="tree.htm#M230" NAME="L3790"><I>treeName</I> <B>values</B> <I>node</I> ?<I>key</I>? ?<I>withnames</I>?</A> |
| 277 |
<DD><A HREF="tree.htm#M231" NAME="L3791"><I>treeName</I> <B>vecdump</B> <I>vector</I> <I>key</I> ?<I>tagnode</I>?</A> |
| 278 |
<DD><A HREF="tree.htm#M232" NAME="L3792"><I>treeName</I> <B>vecload</B> <I>vector</I> <I>key</I> ?<I>tagnode</I>?</A> |
| 279 |
<DD><A HREF="tree.htm#M233" NAME="L3793"><I>treeName</I> <B>with</B> ?<I>switch</I>? <I>tagnode script</I></A> |
| 280 |
<DL class="tree operations"> |
| 281 |
<DD><A HREF="tree.htm#M234" NAME="L3794"><B>-array</B> <I>key</I></A> |
| 282 |
<DD><A HREF="tree.htm#M235" NAME="L3795"><B>-break</B></A> |
| 283 |
<DD><A HREF="tree.htm#M236" NAME="L3796"><B>-keys</B> <I>keylist</I></A> |
| 284 |
<DD><A HREF="tree.htm#M237" NAME="L3797"><B>-noupdate</B></A> |
| 285 |
<DD><A HREF="tree.htm#M238" NAME="L3798"><B>-unset</B></A> |
| 286 |
</DL> |
| 287 |
</DL> |
| 288 |
<DD><A HREF="tree.htm#M239" NAME="L3799">ARRAY SUB-FIELDS</A> |
| 289 |
<DD><A HREF="tree.htm#M240" NAME="L3800">TAG OPERATIONS</A> |
| 290 |
<DL class="tag operations"> |
| 291 |
<DD><A HREF="tree.htm#M241" NAME="L3801"><I>treeName</I> <B>tag add</B> <I>string</I> ?<I>node</I>?...</A> |
| 292 |
<DD><A HREF="tree.htm#M242" NAME="L3802"><I>treeName</I> <B>tag delete</B> <I>string</I> <I>node</I>...</A> |
| 293 |
<DD><A HREF="tree.htm#M243" NAME="L3803"><I>treeName</I> <B>tag dump</B> <I>tagnode</I> ?<I>switches</I>?</A> |
| 294 |
<DL class="tag operations"> |
| 295 |
<DD><A HREF="tree.htm#M244" NAME="L3804"><B>-keys </B><I>list</I></A> |
| 296 |
<DD><A HREF="tree.htm#M245" NAME="L3805"><B>-skipkeys </B><I>list</I></A> |
| 297 |
<DD><A HREF="tree.htm#M246" NAME="L3806"><B>-tag </B><I>pattern</I></A> |
| 298 |
<DD><A HREF="tree.htm#M247" NAME="L3807"><B>-skiptag </B><I>pattern</I></A> |
| 299 |
<DD><A HREF="tree.htm#M248" NAME="L3808"><B>-notags</B></A> |
| 300 |
<DD><A HREF="tree.htm#M249" NAME="L3809"><B>-nopath</B></A> |
| 301 |
</DL> |
| 302 |
<DD><A HREF="tree.htm#M250" NAME="L3810"><I>treeName</I> <B>tag exists</B> <I>string</I> ?<I>id</I>?</A> |
| 303 |
<DD><A HREF="tree.htm#M251" NAME="L3811"><I>treeName</I> <B>tag forget</B> <I>string</I> ?<I>string</I> ...?</A> |
| 304 |
<DD><A HREF="tree.htm#M252" NAME="L3812"><I>treeName</I> <B>tag lookups</B> ?<I>pattern</I>?</A> |
| 305 |
<DD><A HREF="tree.htm#M253" NAME="L3813"><I>treeName</I> <B>tag names</B> ?<B>-glob</B>? ?<B>-regexp</B>? ?<B>-nocase</B>? ?<I>node</I>? ?<I>node ...</I>?</A> |
| 306 |
<DD><A HREF="tree.htm#M254" NAME="L3814"><I>treeName</I> <B>tag nodes</B> <I>string</I> ?<I>string ...</I>?</A> |
| 307 |
</DL> |
| 308 |
<DD><A HREF="tree.htm#M255" NAME="L3815">TRACE OPERATIONS</A> |
| 309 |
<DL class="trace operations"> |
| 310 |
<DD><A HREF="tree.htm#M256" NAME="L3816"><I>treeName</I> <B>trace create</B> <I>node</I> <I>key</I> <I>ops</I> <I>command</I> ?-bgerror?</A> |
| 311 |
<DL class="trace operations"> |
| 312 |
<DD><A HREF="tree.htm#M257" NAME="L3817"><B>r</B></A> |
| 313 |
<DD><A HREF="tree.htm#M258" NAME="L3818"><B>w</B></A> |
| 314 |
<DD><A HREF="tree.htm#M259" NAME="L3819"><B>c</B></A> |
| 315 |
<DD><A HREF="tree.htm#M260" NAME="L3820"><B>u</B></A> |
| 316 |
<DD><A HREF="tree.htm#M261" NAME="L3821"><B>e</B></A> |
| 317 |
<DD><A HREF="tree.htm#M262" NAME="L3822"><B>t</B></A> |
| 318 |
<DD><A HREF="tree.htm#M263" NAME="L3823"><B>m</B></A> |
| 319 |
<DD><A HREF="tree.htm#M264" NAME="L3824"><B>d</B></A> |
| 320 |
</DL> |
| 321 |
<DD><A HREF="tree.htm#M265" NAME="L3825"><I>treeName</I> <B>trace delete</B> <I>traceId</I>...</A> |
| 322 |
<DD><A HREF="tree.htm#M266" NAME="L3826"><I>treeName</I> <B>trace info</B> <I>traceId</I></A> |
| 323 |
<DD><A HREF="tree.htm#M267" NAME="L3827"><I>treeName</I> <B>trace names</B></A> |
| 324 |
</DL> |
| 325 |
<DD><A HREF="tree.htm#M268" NAME="L3828">NOTIFY OPERATIONS</A> |
| 326 |
<DL class="notify operations"> |
| 327 |
<DD><A HREF="tree.htm#M269" NAME="L3829"><I>treeName</I> <B>notify create</B> ?<I>switches</I>? <I>command</I> ?<I>args</I>?...</A> |
| 328 |
<DL class="notify operations"> |
| 329 |
<DD><A HREF="tree.htm#M270" NAME="L3830"><B>-create</B></A> |
| 330 |
<DD><A HREF="tree.htm#M271" NAME="L3831"><B>-delete</B></A> |
| 331 |
<DD><A HREF="tree.htm#M272" NAME="L3832"><B>-get</B></A> |
| 332 |
<DD><A HREF="tree.htm#M273" NAME="L3833"><B>-insert</B></A> |
| 333 |
<DD><A HREF="tree.htm#M274" NAME="L3834"><B>-move</B></A> |
| 334 |
<DD><A HREF="tree.htm#M275" NAME="L3835"><B>-movepost</B></A> |
| 335 |
<DD><A HREF="tree.htm#M276" NAME="L3836"><B>-sort</B></A> |
| 336 |
<DD><A HREF="tree.htm#M277" NAME="L3837"><B>-relabel</B></A> |
| 337 |
<DD><A HREF="tree.htm#M278" NAME="L3838"><B>-relabelpost</B></A> |
| 338 |
<DD><A HREF="tree.htm#M279" NAME="L3839"><B>-allevents</B></A> |
| 339 |
<DD><A HREF="tree.htm#M280" NAME="L3840"><B>-whenidle</B></A> |
| 340 |
</DL> |
| 341 |
<DD><A HREF="tree.htm#M281" NAME="L3841"><I>treeName</I> <B>notify delete</B> <I>notifyId</I></A> |
| 342 |
<DD><A HREF="tree.htm#M282" NAME="L3842"><I>treeName</I> <B>notify info</B> <I>notifyId</I></A> |
| 343 |
<DD><A HREF="tree.htm#M283" NAME="L3843"><I>treeName</I> <B>notify names</B></A> |
| 344 |
</DL> |
| 345 |
<DD><A HREF="tree.htm#M284" NAME="L3844">TABLE EXAMPLE</A> |
| 346 |
<DD><A HREF="tree.htm#M285" NAME="L3845">TREE EXAMPLE</A> |
| 347 |
<DD><A HREF="tree.htm#M286" NAME="L3846">SQLLOAD EXAMPLE</A> |
| 348 |
<DD><A HREF="tree.htm#M287" NAME="L3847">TREE KEY STRING STORAGE</A> |
| 349 |
<DD><A HREF="tree.htm#M288" NAME="L3848">C LANGUAGE API</A> |
| 350 |
<DD><A HREF="tree.htm#M289" NAME="L3849">KEYWORDS</A> |
| 351 |
</DL> |
| 352 |
<H3><A NAME="M2">NAME</A></H3> |
| 353 |
tree - Create and manage tree data objects. |
| 354 |
<H3><A NAME="M3">SYNOPSIS</A></H3> |
| 355 |
<B>tree create</B> ?<B>-fixed</B>? ?<B>-keyhash</B> <I>N</I>? ?<I>treeName</I>?<BR> |
| 356 |
<B>tree destroy</B> <I>treeName</I>...<BR> |
| 357 |
<B>tree names</B> ?<I>pattern</I>?<BR> |
| 358 |
<B>tree op</B> <I>subcmd</I> ?<I>subsubcmd ...</I>? <I>treeName</I> ?<I>arg arg ...</I>?<BR> |
| 359 |
<H3><A NAME="M4">DESCRIPTION</A></H3> |
| 360 |
The <B>tree</B> command is used to create, destroy, list and |
| 361 |
access tree data objects. |
| 362 |
A <I>tree object</I> |
| 363 |
is an ordered tree of nodes where each node has a label and a set of |
| 364 |
key-value data pairs. Creating a tree object associates it with, |
| 365 |
a Tcl command that is subsequently used to interact with the tree. |
| 366 |
Tree objects can also be managed via the C API, eg. |
| 367 |
the <B><A HREF="../TclCmd/treeview.htm">treeview</A></B> widget uses a tree object internally. |
| 368 |
|
| 369 |
<H3><A NAME="M5">INTRODUCTION</A></H3> |
| 370 |
Tree provides Tcl with rich support for storing and accessing |
| 371 |
complex data structures. |
| 372 |
Here is an example. |
| 373 |
<PRE>set t [tree create] |
| 374 |
set n [$t insert 0 -data {a 1 b 2 c "X 1 Y 2"}] |
| 375 |
$t set $n b [$t get $n a] |
| 376 |
$t set $n c(X) 4</PRE> |
| 377 |
<P> |
| 378 |
Note the last line demonstrates an <B><A HREF="../TclCmd/array.htm">array</A></B> value. |
| 379 |
See the |
| 380 |
section below for details. |
| 381 |
<H3><A NAME="M6">SYNTAX</A></H3> |
| 382 |
<DL class="syntax"> |
| 383 |
<DT><A NAME="M7"><B>tree create</B> ?<B>-fixed</B>? ?<B>-keyhash</B> <I>N</I>? ?<I>treeName</I>?</A><DD> |
| 384 |
Creates a new tree object. The name of the new tree is returned. |
| 385 |
If no <I>treeName</I> argument is present, then the name of the tree is |
| 386 |
automatically generated in the form "<B>tree0</B>", "<B>tree1</B>", |
| 387 |
etc relative to the current namespace. |
| 388 |
If a tree names is given, it can not start with a dash. |
| 389 |
If the substring "<B>#auto</B>" is found in a given <I>treeName</I>, it |
| 390 |
is replaced with <B>tree</B><I>N</I> in a |
| 391 |
generated name. For example, the |
| 392 |
name <B>foo.#auto.bar</B> will translate to <B>foo.tree0.bar</B>. |
| 393 |
<P> |
| 394 |
A Tcl command (with the same name as the tree) is also created. |
| 395 |
Another Tcl command or tree object can not already exist named |
| 396 |
<I>treeName</I>. If the Tcl command is deleted, the tree will also be |
| 397 |
freed. |
| 398 |
<P> |
| 399 |
Newly created trees always contain a single root node with id <B>0</B> |
| 400 |
that can not be deleted. |
| 401 |
<P> |
| 402 |
Switches for <B>create</B> are listed below: |
| 403 |
<P> |
| 404 |
<DL class="syntax"> |
| 405 |
<DT><A NAME="M8"><B>-fixed</B></A><DD> |
| 406 |
Make <B>insert</B> automatically set the <B>-fixed</B> flag. |
| 407 |
This will disallow later setting of keys not given |
| 408 |
as <I>-data</I> to the insert. Also see <B>fixed</B>. |
| 409 |
<P><DT><A NAME="M9"><B>-keyhash</B> <I>size</I></A><DD> |
| 410 |
Define the size beyond which node key storage starts using |
| 411 |
a hash (the default is 21 keys). Normally |
| 412 |
small numbers of keys are stored as a list. But once more than |
| 413 |
<I>size</I> keys are added to a node, key storage converts to a hash. |
| 414 |
This affects the order of key iteration (eg. for <B>get</B>/<B>names</B>/<B>values</B>). |
| 415 |
A list will iterate in the order in which keys were added, |
| 416 |
whereas the order of a hash is undetermined. |
| 417 |
For large numbers of |
| 418 |
ordered keys, specify a really large <I>size</I> (eg. 1000000). |
| 419 |
Note that array sub-keys always use a hash table. |
| 420 |
<P></DL> |
| 421 |
<P><DT><A NAME="M10"><B>tree destroy</B> <I>treeName</I>...</A><DD> |
| 422 |
Releases one of more trees. The Tcl command associated with |
| 423 |
<I>treeName</I> is also removed. Trees are reference counted. The |
| 424 |
internal tree data object isn't destroyed until no one else is using |
| 425 |
the tree. |
| 426 |
<P><DT><A NAME="M11"><B>tree names</B> ?<I>pattern</I>?</A><DD> |
| 427 |
Returns the names of all tree objects. if a <I>pattern</I> argument |
| 428 |
is given, then the only those trees whose name matches pattern will |
| 429 |
be listed. |
| 430 |
<P><DT><A NAME="M12"><B>tree op</B> <I>subcmd</I> ?<I>subsubcmd ...</I>? <I>treeName</I> ?<I>arg arg ...</I>?</A><DD> |
| 431 |
Provide direct calls to sub-commands, without going through the object command. |
| 432 |
Aside from self documentating, |
| 433 |
it allows wize to provide support checked tree calls. |
| 434 |
<P></DL> |
| 435 |
<H3><A NAME="M13">NODE IDS AND TAGS</A></H3> |
| 436 |
Nodes in a tree object may be referred in either of two ways: by id or by |
| 437 |
tag. Each node has a unique serial number or id that is assigned to that |
| 438 |
node when it's created. The id of an node never changes and id numbers |
| 439 |
are not re-used (except when all of roots nodes are delete). |
| 440 |
<P> |
| 441 |
A node may also have any number of tags associated with it. A tag is |
| 442 |
just a string of characters, and it may take any form but |
| 443 |
may not start with |
| 444 |
an integer. For example, "<B>x123</B>" is valid, but "<B>123x</B>" |
| 445 |
is not. The same tag may be associated with one |
| 446 |
or multiple nodes (ranges or <I>tagnode</I>). |
| 447 |
Ranges are commonly used to group nodes in various interesting ways. |
| 448 |
<P> |
| 449 |
Commands that take a <I>tagnode</I> can operate on ranges and |
| 450 |
will accept either a tag or a list of zero or more integer node numbers. |
| 451 |
Node-lists can contain only integers, |
| 452 |
without leading spaces. |
| 453 |
Node-lists simplify the use of iterating commands because |
| 454 |
it avoids excessive use of <B><A HREF="../TclCmd/eval.htm">eval</A></B>. |
| 455 |
<P> |
| 456 |
There are four built-in tags: |
| 457 |
<P> |
| 458 |
<DL class="node ids and tags"> |
| 459 |
<DT><A NAME="M14"><B>all</B></A><DD> |
| 460 |
Applies to every node in the tree. |
| 461 |
<P><DT><A NAME="M15"><B>nonroot</B></A><DD> |
| 462 |
Applies to every node in the tree except the root node. |
| 463 |
<P><DT><A NAME="M16"><B>rootchildren</B></A><DD> |
| 464 |
Applies to every node in the tree whose parent is the root node. |
| 465 |
<P><DT><A NAME="M17"><B>root</B></A><DD> |
| 466 |
Managed automatically by the tree object, <B>root</B> specifies the node |
| 467 |
that is currently set as the root node for the tree. |
| 468 |
<P></DL> |
| 469 |
<P> |
| 470 |
When specifying nodes in tree object commands, if the specifier is an |
| 471 |
integer then it is assumed to refer to the single node with that id. |
| 472 |
If the specifier is not an integer, then it is assumed to refer to all |
| 473 |
of the nodes in the tree that have a tag matching the specifier. The |
| 474 |
symbol <I>node</I> is used below to indicate that an argument specifies |
| 475 |
either an id or a tag that selects a single node. |
| 476 |
A <I>tagnode</I> is either a tag that selects a group of |
| 477 |
nodes, or it's a list of zero or more integer node numbers. |
| 478 |
Many tree commands only operate on a single node at a |
| 479 |
time; if <I>node</I> is specified in a way that names multiple items, then |
| 480 |
an error "refers to more than one node" is generated. |
| 481 |
<H3><A NAME="M18">NODE MODIFIERS</A></H3> |
| 482 |
You can also specify node in relation to another node by appending one |
| 483 |
or more modifiers to the node id or tag. A modifier refers to a node |
| 484 |
in relation to the specified node. For example, |
| 485 |
"<B>root->firstchild</B>" |
| 486 |
selects the first subtree of the root node. |
| 487 |
<P> |
| 488 |
The following modifiers are available: |
| 489 |
<P> |
| 490 |
<DL class="node modifiers"> |
| 491 |
<DT><A NAME="M19"><B>firstchild</B></A><DD> |
| 492 |
Selects the first child of the node. |
| 493 |
<P><DT><A NAME="M20"><B>lastchild</B></A><DD> |
| 494 |
Selects the last child of the node. |
| 495 |
<P><DT><A NAME="M21"><B>nextnode</B></A><DD> |
| 496 |
Selects the next node in preorder to the node. |
| 497 |
<P><DT><A NAME="M22"><B>nextsibling</B></A><DD> |
| 498 |
Selects the next sibling of the node. |
| 499 |
<P><DT><A NAME="M23"><B>parentnode</B></A><DD> |
| 500 |
Selects the parent of the node. |
| 501 |
<P><DT><A NAME="M24"><B>prevnode</B></A><DD> |
| 502 |
Selects the previous node in preorder to the node. |
| 503 |
<P><DT><A NAME="M25"><B>prevsibling</B></A><DD> |
| 504 |
Selects the previous sibling of the node. |
| 505 |
<P><DT><A NAME="M26"><B>maxnode</B></A><DD> |
| 506 |
The maximum node number. |
| 507 |
<P><DT><A NAME="M27">"<I>label</I>"</A><DD> |
| 508 |
<P><DT><A NAME="M28">'<I>label</I>'</A><DD> |
| 509 |
Selects the child node whose label is <I>label</I>. Enclosing <I>label</I> in |
| 510 |
quotes (double or single) |
| 511 |
indicates to search for a node by its label (for example, |
| 512 |
even if the node is labeled "parentnode"). If mulitiple child nodes |
| 513 |
have the given label, the first node is used. |
| 514 |
<P></DL> |
| 515 |
<P> |
| 516 |
It's an error if the node can't be found. For example, |
| 517 |
<B>lastchild</B> and <B>firstchild</B> will generate errors if the node |
| 518 |
has no children. The exception to this is the <B>index</B> operation. |
| 519 |
You can use <B>index</B> to test if a modifier is valid. |
| 520 |
<H3><A NAME="M29">TREE OPERATIONS</A></H3> |
| 521 |
Once you create a tree object, you can use its Tcl command |
| 522 |
to query or modify it. The |
| 523 |
general form is |
| 524 |
<dl><dd><table border="0"><tr><td><p style="font-size:12px;padding-left:.5em;padding-right:.5em;"><I>treeName</I> <I>operation</I> ?<I>arg</I>?...</table></dl> |
| 525 |
Both <I>operation</I> and its arguments determine the exact behavior of |
| 526 |
the command. The operations available for trees are listed below. |
| 527 |
<P> |
| 528 |
<DL class="tree operations"> |
| 529 |
<DT><A NAME="M30"><I>treeName</I> <B>ancestor</B> <I>node1</I> <I>node2</I></A><DD> |
| 530 |
Returns the mutual ancestor of the two nodes <I>node1</I> and |
| 531 |
<I>node2</I>. The ancestor can be one of the two nodes. For example, |
| 532 |
if <I>node1</I> and <I>node2</I> are the same nodes, their ancestor is |
| 533 |
<I>node1</I>. |
| 534 |
<P><DT><A NAME="M31"><I>treeName</I> <B>append</B> <I>node key</I> <I>string</I> ?<I>string ...</I>?</A><DD> |
| 535 |
Append one or more strings to node/key value. |
| 536 |
<P><DT><A NAME="M32"><I>treeName</I> <B>appendi</B> <I>tagnode key</I> <I>string</I> ?<I>string ...</I>?</A><DD> |
| 537 |
The same as <B><A HREF="../TclCmd/append.htm">append</A></B> but accepts a multi-node tag and an |
| 538 |
undefined key will be initialized to {}. Returns the number of nodes |
| 539 |
updated. |
| 540 |
<P><DT><A NAME="M33"><I>treeName</I> <B>apply</B> <I>node</I> ?<I>switches</I>?</A><DD> |
| 541 |
Runs commands for all nodes matching the criteria given by |
| 542 |
<I>switches</I> for the subtree designated by <I>node</I>. By default |
| 543 |
all nodes match, but you can set switches to narrow the match. This |
| 544 |
operation differs from <B>find</B> in two ways: 1) Tcl commands can be |
| 545 |
invoked both pre- and post-traversal of a node and 2) the tree is |
| 546 |
always traversed in depth first order. |
| 547 |
<P> |
| 548 |
The <B>-exact</B>, <B>-glob</B>, |
| 549 |
and <B>-regexp</B> switches indicate both what kind of pattern matching |
| 550 |
to perform and the pattern. By default each pattern will be compared |
| 551 |
with the node label. You can set more than one of these switches. If |
| 552 |
any of the patterns match (logical or), the node matches. |
| 553 |
If the <B>-key</B> switch is |
| 554 |
used, it designates the data field to be matched. |
| 555 |
<P> |
| 556 |
The valid switches are listed |
| 557 |
below: |
| 558 |
<P> |
| 559 |
<DL class="tree operations"> |
| 560 |
<DT><A NAME="M34"><B>-depth</B> <I>number</I></A><DD> |
| 561 |
Descend at most <I>number</I> (a non-negative integer) levels |
| 562 |
If <I>number</I> is <B>1</B> this means only apply the tests |
| 563 |
to the children of <I>node</I>. |
| 564 |
<P><DT><A NAME="M35"><B>-exact</B> <I>string</I></A><DD> |
| 565 |
Matches each node using <I>string</I>. The node must match <I>string</I> |
| 566 |
exactly. |
| 567 |
<P><DT><A NAME="M36"><B>-glob</B> <I>string</I></A><DD> |
| 568 |
Test each node to <I>string</I> using global pattern |
| 569 |
matching. Matching is done in a fashion similar to that used by |
| 570 |
<B><A HREF="../TclCmd/string.htm">string match</A></B>. |
| 571 |
<P><DT><A NAME="M37"><B>-invert</B></A><DD> |
| 572 |
Invert the results of the pattern matching of <B>-name</B>. |
| 573 |
<P><DT><A NAME="M38"><B>-isleaf</B></A><DD> |
| 574 |
Only test nodes with no children. |
| 575 |
<P><DT><A NAME="M39"><B>-istree</B></A><DD> |
| 576 |
Only test nodes with children. |
| 577 |
<P><DT><A NAME="M40"><B>-key</B> <I>key</I></A><DD> |
| 578 |
<P><DT><A NAME="M41"><B>-keyglob</B> <I>key</I></A><DD> |
| 579 |
<P><DT><A NAME="M42"><B>-keyregexp</B> <I>key</I></A><DD> |
| 580 |
<P><DT><A NAME="M43"><B>-keyexact</B> <I>key</I></A><DD> |
| 581 |
If pattern matching is selected (using the <B>-exact</B>, |
| 582 |
<B>-glob</B>, or <B>-regexp</B> switches), compare the values of the |
| 583 |
data field keyed by <I>key</I> instead of the node's label. If no |
| 584 |
pattern matching switches are set, then any node with this data key |
| 585 |
will match. The field names may also be patterns using <B>-keyglob</B>, etc. |
| 586 |
<P><DT><A NAME="M44"><B>-nocase</B></A><DD> |
| 587 |
Ignore case when matching patterns. |
| 588 |
<P><DT><A NAME="M45"><B>-precommand</B> <I>command</I></A><DD> |
| 589 |
Invoke <I>command</I> for each matching node. Before <I>command</I> is |
| 590 |
invoked, the id of the node is appended. You can control |
| 591 |
processing by the return value of <I>command</I>. If <I>command</I> |
| 592 |
generates an error, processing stops and the <B>find</B> operation |
| 593 |
returns an error. But if <I>command</I> returns <B><A HREF="../TclCmd/break.htm">break</A></B>, then |
| 594 |
processing stops, no error is generated. If <I>command</I> returns |
| 595 |
<B><A HREF="../TclCmd/continue.htm">continue</A></B>, then processing |
| 596 |
stops on that subtree and continues on the next. |
| 597 |
<P><DT><A NAME="M46"><B>-postcommand</B> <I>command</I></A><DD> |
| 598 |
Invoke <I>command</I> for each matching node. Before <I>command</I> is |
| 599 |
invoked, the id of the node is appended. You can control |
| 600 |
processing by the return value of <I>command</I>. If <I>command</I> |
| 601 |
generates an error, processing stops and the <B>find</B> operation |
| 602 |
returns an error. But if <I>command</I> returns <B><A HREF="../TclCmd/break.htm">break</A></B>, then |
| 603 |
processing stops, no error is generated. If <I>command</I> returns |
| 604 |
<B><A HREF="../TclCmd/continue.htm">continue</A></B>, then processing |
| 605 |
stops on that subtree and continues on the next. |
| 606 |
<P><DT><A NAME="M47"><B>-regexp</B> <I>string</I></A><DD> |
| 607 |
Test each node using <I>string</I> as a regular expression pattern. |
| 608 |
<P><DT><A NAME="M48"><B>-tag</B> <I>string</I></A><DD> |
| 609 |
Only test nodes that have the tag <I>string</I>. |
| 610 |
<P><DT><A NAME="M49"><B>-usepath</B></A><DD> |
| 611 |
Use the node's full path when comparing nodes. The node's full |
| 612 |
path is a list of labels, starting from the root of each ancestor |
| 613 |
and the node label. The default is to compare only the node label. |
| 614 |
<P></DL> |
| 615 |
<P><DT><A NAME="M50"><I>treeName</I> <B>children</B> ?<B>-labels</B>? <I>node</I> ?<I>first</I>? ?<I>last</I>?</A><DD> |
| 616 |
Returns a list of children for <I>node</I>. If <I>node</I> is a leaf, |
| 617 |
then an empty string is returned. If <I>first</I> and/or <I>last</I> |
| 618 |
are given they are the integer index of the children to display. |
| 619 |
If the <B>-labels</B> option is used, |
| 620 |
labels are returned instead of the nodes. |
| 621 |
<P><DT><A NAME="M51"><I>treeName</I> <B>copy</B> <I>srcNode</I> ?<I>destTree</I>? <I>parentNode</I> ?<I>switches</I>?</A><DD> |
| 622 |
Copies <I>srcNode</I> into <I>parentNode</I>. Both nodes <I>srcNode</I> and |
| 623 |
<I>parentNode</I> must already exist. The id of the new node is |
| 624 |
returned. You can copy from one tree to another. If a <I>destTree</I> |
| 625 |
argument is present, it indicates the name of the destination tree. |
| 626 |
By default both the source and destination trees are the same. The valid |
| 627 |
<I>switches</I> are listed below: |
| 628 |
<P> |
| 629 |
<DL class="tree operations"> |
| 630 |
<DT><A NAME="M52"><B>-label</B> <I>string</I></A><DD> |
| 631 |
Label <I>destNode</I> as <I>string</I>. By default, <I>destNode</I> has |
| 632 |
the same label as <I>srcNode</I>. |
| 633 |
<P><DT><A NAME="M53"><B>-overwrite</B></A><DD> |
| 634 |
Overwrite nodes that already exist. Normally nodes are always |
| 635 |
created, even if there already exists a node by the same name. This |
| 636 |
switch indicates to add or overwrite the node's data fields. |
| 637 |
<P><DT><A NAME="M54"><B>-recurse</B></A><DD> |
| 638 |
Recursively copy all the subtrees of <I>srcNode</I> as well. In this case, |
| 639 |
<I>srcNode</I> can't be an ancestor of <I>destNode</I> as it would result |
| 640 |
in a cyclic copy. |
| 641 |
<P><DT><A NAME="M55"><B>-reverse</B></A><DD> |
| 642 |
Reverse the direction of the copy. |
| 643 |
<P><DT><A NAME="M56"><B>-tags</B></A><DD> |
| 644 |
Copy tag inforation. Normally the following node is copied: its |
| 645 |
label and data fields. This indicates to copy tags as well. |
| 646 |
<P></DL> |
| 647 |
<P><DT><A NAME="M57"><I>treeName</I> <B>create</B> ?<I>switches</I>?</A><DD> |
| 648 |
Cause the creation of zero or more nodes. |
| 649 |
Exactly one of <B>-num</B>, <B>-nodes</B> or <B>-path</B> is required. |
| 650 |
This can create all nodes in a given <B>-path</B> |
| 651 |
or efficiently populate a tree with large numbers |
| 652 |
of nodes. |
| 653 |
The return values is the id of the last created node (or <B>-path</B> element). |
| 654 |
The valid flags for <I>switches</I> are described below. |
| 655 |
<P> |
| 656 |
<DL class="tree operations"> |
| 657 |
<DT><A NAME="M58"><B>-at</B> <I>number</I></A><DD> |
| 658 |
Where to insert child nodes. |
| 659 |
The default is -1, meaning append. |
| 660 |
<P><DT><A NAME="M59"><B>-fixed</B></A><DD> |
| 661 |
Set the fixed flag. |
| 662 |
<P><DT><A NAME="M60"><B>-data</B> <I>list</I></A><DD> |
| 663 |
Data to set in each node. |
| 664 |
<P><DT><A NAME="M61"><B>-labelstart</B> <I>number</I></A><DD> |
| 665 |
The label generated nodes is to use |
| 666 |
a sequence number starting from <I>number</I>. |
| 667 |
The default is to just use the node id. |
| 668 |
<P><DT><A NAME="M62"><B>-nodes</B> <I>list</I></A><DD> |
| 669 |
List of nodes ids to create. |
| 670 |
The <B>-offset</B> option can specify |
| 671 |
a constant to add. |
| 672 |
<P><DT><A NAME="M63"><B>-num</B> <I>number</I></A><DD> |
| 673 |
The number of nodes to create. |
| 674 |
<P><DT><A NAME="M64"><B>-offset</B> <I>number</I></A><DD> |
| 675 |
Number to add to each element in <B>-nodes</B>. |
| 676 |
For example, if loading sqlite rowids you should use 1. |
| 677 |
The default is 0. |
| 678 |
<P><DT><A NAME="M65"><B>-parent</B> <I>node</I></A><DD> |
| 679 |
The <I>node</I> to insert children into. |
| 680 |
The default is the root node. |
| 681 |
<P><DT><A NAME="M66"><B>-path</B> <I>pathList</I></A><DD> |
| 682 |
Verify that a path exists and create any missing nodes. |
| 683 |
Uses labels in <I>pathList</I> to lookup nodes, creating |
| 684 |
them if not found. The id for the last |
| 685 |
node in the path is returned (created or not). |
| 686 |
<P><DT><A NAME="M67"><B>-prefix</B> <I>str</I></A><DD> |
| 687 |
String prefix to add to each nodes label. |
| 688 |
<P><DT><A NAME="M68"><B>-start</B> <I>number</I></A><DD> |
| 689 |
Node nuber to start from when using <B>-num</B>. The default is 1. |
| 690 |
<P><DT><A NAME="M69"><B>-tags</B> <I>tagList</I></A><DD> |
| 691 |
List of tags to add to each newly created node. |
| 692 |
<P></DL> |
| 693 |
<P><DT><A NAME="M70"><I>treeName</I> <B>degree</B> <I>node</I></A><DD> |
| 694 |
Returns the number of children of <I>node</I>. |
| 695 |
<P><DT><A NAME="M71"><I>treeName</I> <B>delete</B> <I>node</I>...</A><DD> |
| 696 |
Recursively deletes one or more nodes from the tree. |
| 697 |
The node and all its descendants are removed. The one exception |
| 698 |
is the root node. In this case, only its descendants are removed. |
| 699 |
The root node will remain. Any tags or |
| 700 |
traces on the nodes are released. |
| 701 |
<P><DT><A NAME="M72"><I>treeName</I> <B>depth</B> <I>node</I></A><DD> |
| 702 |
Returns the depth of the node. The depth is the number of |
| 703 |
steps from the node to the root of the tree. The depth of the |
| 704 |
root node is <B>0</B>. |
| 705 |
<P><DT><A NAME="M73"><I>treeName</I> <B>dump</B> <I>node</I> ?<I>switches</I>?</A><DD> |
| 706 |
Save tree data for <I>node</I> and its descendants. |
| 707 |
With the <B>-file</B> option, output goes to the file |
| 708 |
<I>fileName</I> (this is unsupported in a safe interp). |
| 709 |
With the <B>-channel</B> option, data is output to channel <I>chan</I>. |
| 710 |
If neither option is given, the dump is returned as data. |
| 711 |
<P> |
| 712 |
The subtree designated by <I>node</I> is |
| 713 |
traversed to obtain the following information for each node: 1) the node's |
| 714 |
path relative to <I>node</I>, 2) a sublist key value pairs |
| 715 |
representing the node's data fields, and 3) a sublist of tags. |
| 716 |
and 4) the label |
| 717 |
This list returned can be used |
| 718 |
later to copy or restore the tree with the <B>restore</B> operation. |
| 719 |
<P> |
| 720 |
The valid <I>switches</I> are listed below. |
| 721 |
<P> |
| 722 |
<DL class="tree operations"> |
| 723 |
<DT><A NAME="M74"><B>-channel </B><I>chan</I></A><DD> |
| 724 |
Obtain data from from the given channel <I>chan</I>. |
| 725 |
The channel is not closed afterwards. |
| 726 |
<P><DT><A NAME="M75"><B>-file </B><I>fileName</I></A><DD> |
| 727 |
Obtain data from from the file. |
| 728 |
<I>fileName</I>. This options is unsupported in a safe interp. |
| 729 |
<P><DT><A NAME="M76"><B>-keys </B><I>list</I></A><DD> |
| 730 |
A list of patterns of matching keys to be dumped. |
| 731 |
<P><DT><A NAME="M77"><B>-skipkeys </B><I>list</I></A><DD> |
| 732 |
A list of patterns of matching keys not to be dumped. |
| 733 |
<P><DT><A NAME="M78"><B>-tag </B><I>pattern</I></A><DD> |
| 734 |
A pattern match for tags to include in a node dump. |
| 735 |
<P><DT><A NAME="M79"><B>-skiptag </B><I>pattern</I></A><DD> |
| 736 |
A pattern match for tags to not include in a node dump. |
| 737 |
<P><DT><A NAME="M80"><B>-notags</B></A><DD> |
| 738 |
Do not restore any tags |
| 739 |
<P><DT><A NAME="M81"><B>-nopath</B></A><DD> |
| 740 |
To save space, do not dump the full path for each node. |
| 741 |
Instead output periods for all but the last path element. |
| 742 |
Full paths are used only for partial restores. |
| 743 |
<P></DL> |
| 744 |
<P><DT><A NAME="M82"><I>treeName</I> <B>exists</B> <I>node</I> ?<I>key</I>?</A><DD> |
| 745 |
Indicates if <I>node</I> exists in the tree. If a <I>key</I> argument |
| 746 |
is present then the command also indicates if the named data field |
| 747 |
exists. |
| 748 |
<P><DT><A NAME="M83"><I>treeName</I> <B>find</B> ?<I>switches</I>?</A><DD> |
| 749 |
Finds for all nodes matching the criteria given by <I>switches</I> |
| 750 |
for the subtree designated by <I>node</I>. A list of the selected |
| 751 |
nodes is returned. By default all nodes match, but you can set |
| 752 |
switches to narrow the match. |
| 753 |
<P> |
| 754 |
The <B>-exact</B>, <B>-glob</B>, |
| 755 |
and <B>-regexp</B> switches indicate what kind of pattern matching |
| 756 |
to perform for <B>-name</B>. By default the pattern will be compared |
| 757 |
with the node label. If the <B>-key</B> switch is |
| 758 |
used, it designates the data field to be matched. |
| 759 |
<P> |
| 760 |
The order in |
| 761 |
which the nodes are traversed is controlled by the <B>-order</B> switch. |
| 762 |
The possible orderings are <B>preorder</B>, <B>postorder</B>, <B>inorder</B>, |
| 763 |
and <B>breadthfirst</B>. The default is <B>preorder</B>. |
| 764 |
<P> |
| 765 |
The valid switches are listed |
| 766 |
below: |
| 767 |
<P> |
| 768 |
<DL class="tree operations"> |
| 769 |
<DT><A NAME="M84"><B>-addtag</B> <I>string</I></A><DD> |
| 770 |
Add the tag <I>string</I> to each selected node. |
| 771 |
<P><DT><A NAME="M85"><B>-command</B> <I>command</I></A><DD> |
| 772 |
Invoke <I>command</I> for each matching node. Before <I>command</I> is |
| 773 |
invoked, the id of the node is appended. You can control |
| 774 |
processing by the return value of <I>command</I>. If <I>command</I> |
| 775 |
generates an error, processing stops and the <B>find</B> operation |
| 776 |
returns an error. But if <I>command</I> returns <B><A HREF="../TclCmd/break.htm">break</A></B>, then |
| 777 |
processing stops, no error is generated. If <I>command</I> returns |
| 778 |
<B><A HREF="../TclCmd/continue.htm">continue</A></B>, then processing |
| 779 |
stops on that subtree and continues on the next. |
| 780 |
<P><DT><A NAME="M86"><B>-count</B></A><DD> |
| 781 |
Just return the number of matches. |
| 782 |
<P><DT><A NAME="M87"><B>-depth</B> <I>number</I></A><DD> |
| 783 |
Include only nodes with level equal to <I>number</I>. |
| 784 |
<P><DT><A NAME="M88"><B>-exact</B></A><DD> |
| 785 |
Matches each node exactly. |
| 786 |
<P><DT><A NAME="M89"><B>-exec</B> <I>script</I></A><DD> |
| 787 |
Specifies a Tcl script to be evaluated for each matching node. |
| 788 |
If <B>-var</B> was also specified, that variable is set with the value of |
| 789 |
the node id before each evaluation. Otherwise, |
| 790 |
percent sustitutions are performed: note this is much |
| 791 |
less efficient than using either <B>-var</B> or <B>-command</B> |
| 792 |
<P> |
| 793 |
The result of each eval gets appended to the return list, unless |
| 794 |
the script issues a CONTINUE, in which case that node is skipped. |
| 795 |
<P> |
| 796 |
The available percent substitutions on <I>string</I> are: |
| 797 |
<P> |
| 798 |
<DL class="tree operations"> |
| 799 |
<DT><A NAME="M90"><B>%#</B></A><DD> |
| 800 |
The id of the node. |
| 801 |
<P><DT><A NAME="M91"><B>%W</B></A><DD> |
| 802 |
The pathname of the tree. |
| 803 |
<P><DT><A NAME="M92"><B>%p</B></A><DD> |
| 804 |
The label of the node. |
| 805 |
<P><DT><A NAME="M93"><B>%P</B></A><DD> |
| 806 |
The full pathname of the node. |
| 807 |
<P><DT><A NAME="M94"><B>%R</B></A><DD> |
| 808 |
The -> delimited path from root, eg. "root->able->baker->charlie" |
| 809 |
<P><DT><A NAME="M95"><B>%r</B></A><DD> |
| 810 |
The -> delimited path from 0, eg. "0->able->baker->charlie" |
| 811 |
<P><DT><A NAME="M96"><B>%T</B></A><DD> |
| 812 |
The dot delimited tag path eg. ".able.baker.charlie" |
| 813 |
<P><DT><A NAME="M97"><B>%V</B></A><DD> |
| 814 |
The value if using <B>-key</B> or the label otherwise. |
| 815 |
<P><DT><A NAME="M98"><B>%D</B></A><DD> |
| 816 |
The data for the node, ie. like that returned from <B>get</B>. |
| 817 |
<P><DT><A NAME="M99"><B>%%</B></A><DD> |
| 818 |
Translates to a single percent. |
| 819 |
<P></DL> |
| 820 |
<P><DT><A NAME="M100"><B>-glob</B></A><DD> |
| 821 |
Test each node using global pattern |
| 822 |
matching. Matching is done in a fashion similar to that used by the |
| 823 |
<B><A HREF="../TclCmd/string.htm">string match</A></B>. |
| 824 |
<P><DT><A NAME="M101"><B>-isarray</B></A><DD> |
| 825 |
Only test nodes where the specified <B>-key</B> value |
| 826 |
is an array. Can not be used with <B>-name</B>. |
| 827 |
The <B>-invert</B> flag will invert the meaning of the |
| 828 |
check. Note that this will attempt to convert the key value in |
| 829 |
each traversed node into an array type. |
| 830 |
<P><DT><A NAME="M102"><B>-invert</B></A><DD> |
| 831 |
Invert the pattern matching of <B>-name</B>. |
| 832 |
<P><DT><A NAME="M103"><B>-isfixed</B></A><DD> |
| 833 |
Only test nodes that have used <B>fixed 1</B>. |
| 834 |
<P><DT><A NAME="M104"><B>-isleaf</B></A><DD> |
| 835 |
Only test nodes with no children. |
| 836 |
<P><DT><A NAME="M105"><B>-isnotfixed</B></A><DD> |
| 837 |
Only test nodes that have not used <B>fixed 1</B>. |
| 838 |
<P><DT><A NAME="M106"><B>-istree</B></A><DD> |
| 839 |
Only test nodes with children. |
| 840 |
<P><DT><A NAME="M107"><B>-keycount</B> <I>num</I></A><DD> |
| 841 |
Only test if number of keys is equal to <I>num</I>. |
| 842 |
<P><DT><A NAME="M108"><B>-key</B> <I>key</I></A><DD> |
| 843 |
<P><DT><A NAME="M109"><B>-keyglob</B> <I>key</I></A><DD> |
| 844 |
<P><DT><A NAME="M110"><B>-keyregexp</B> <I>key</I></A><DD> |
| 845 |
<P><DT><A NAME="M111"><B>-keyexact</B> <I>key</I></A><DD> |
| 846 |
Compare the values of the data field keyed by <I>key</I> instead of |
| 847 |
the node's label. If no <B>-name</B> pattern is used |
| 848 |
then any node with this data key will match. |
| 849 |
The key names may also be patterns using <B>-keyglob</B>, etc. |
| 850 |
<P><DT><A NAME="M112"><B>-limit</B> <I>number</I></A><DD> |
| 851 |
Stop processing after <I>number</I> (a positive integer) matches. |
| 852 |
<P><DT><A NAME="M113"><B>-maxdepth</B> <I>number</I></A><DD> |
| 853 |
Include only nodes at level <I>number</I> or less. |
| 854 |
<P><DT><A NAME="M114"><B>-mindepth</B> <I>number</I></A><DD> |
| 855 |
Include only nodes at level <I>number</I> or greater. |
| 856 |
<P><DT><A NAME="M115"><B>-name</B> <I>string</I></A><DD> |
| 857 |
The name to use for pattern matching. |
| 858 |
<P><DT><A NAME="M116"><B>-nocase</B></A><DD> |
| 859 |
Ignore case when matching patterns. |
| 860 |
<P><DT><A NAME="M117"><B>-nodes </B><I>tagnode</I></A><DD> |
| 861 |
Search only in <I>tagnode</I>, which is either a tag |
| 862 |
or a list of nodes ids. This makes possible nested searches. |
| 863 |
Note this option is incompatible with |
| 864 |
<B>-top</B> and <B>-notop</B>. |
| 865 |
<P><DT><A NAME="M118"><B>-notop</B></A><DD> |
| 866 |
Exclude the <B>-top</B> or starting node. |
| 867 |
<P><DT><A NAME="M119"><B>-order</B> <I>string</I></A><DD> |
| 868 |
Traverse the tree and process nodes according to <I>string</I>. <I>String</I> |
| 869 |
can be one of the following: |
| 870 |
<P> |
| 871 |
<DL class="tree operations"> |
| 872 |
<DT><A NAME="M120"><B>breadthfirst</B></A><DD> |
| 873 |
Process the node and the subtrees at each sucessive level. Each node |
| 874 |
on a level is processed before going to the next level. |
| 875 |
<P><DT><A NAME="M121"><B>inorder</B></A><DD> |
| 876 |
Recursively process the nodes of the first subtree, the node itself, |
| 877 |
and any the remaining subtrees. |
| 878 |
<P><DT><A NAME="M122"><B>postorder</B></A><DD> |
| 879 |
Recursively process all subtrees before the node. |
| 880 |
<P><DT><A NAME="M123"><B>preorder</B></A><DD> |
| 881 |
Recursively process the node first, then any subtrees (default). |
| 882 |
<P></DL> |
| 883 |
<P><DT><A NAME="M124"><B>-usepath</B></A><DD> |
| 884 |
Use the node's full path when doing the comparison. |
| 885 |
The default is to compare only the node label. |
| 886 |
<P><DT><A NAME="M125"><B>-regexp</B></A><DD> |
| 887 |
Test each node using regular expression pattern matching. |
| 888 |
<P><DT><A NAME="M126"><B>-reldepth</B></A><DD> |
| 889 |
Change the meaning of <B>-depth</B>, <B>-mindepth</B> and <B>-maxdepth</B> |
| 890 |
to be relative to the <B>-top</B> node. |
| 891 |
<P><DT><A NAME="M127"><B>-return </B><I>key</I></A><DD> |
| 892 |
Return the value of the given <I>key</I>, or the empty string if none. |
| 893 |
If the given <I>key</I> is the empty string, the node label will be returned. |
| 894 |
If no value was found and the given <I>key</I> starts with a percent |
| 895 |
returns the sustitution as per <B>-exec</B>. Note that a percent |
| 896 |
substitution longer than 2 chars will append values as list elements. |
| 897 |
<P><DT><A NAME="M128"><B>-top </B><I>node</I></A><DD> |
| 898 |
Search is only at <I>node</I> and it's descendants. |
| 899 |
The default is the root node. |
| 900 |
<P><DT><A NAME="M129"><B>-var </B><I>variable</I></A><DD> |
| 901 |
A variable to set with the node id before each iteration of the <B>-exec</B> |
| 902 |
script. |
| 903 |
<P><DT><A NAME="M130"><B>-withtag</B> <I>string</I></A><DD> |
| 904 |
Only test nodes that have the tag <I>string</I>. |
| 905 |
<P><DT><A NAME="M131"><B>-withouttag</B> <I>string</I></A><DD> |
| 906 |
Only test nodes that don't have the tag <I>string</I>. |
| 907 |
<P></DL> |
| 908 |
<P><DT><A NAME="M132"><I>treeName</I> <B>findchild</B> <I>node</I> <I>label</I></A><DD> |
| 909 |
Searches for a child node <I>label</I> in <I>node</I>. The id of the |
| 910 |
child node is returned if found. Otherwise <B>-1</B> is returned. |
| 911 |
This is the same as using <B>index </B><I>node->label</I>. |
| 912 |
<P><DT><A NAME="M133"><I>treeName</I> <B>firstchild</B> <I>node</I></A><DD> |
| 913 |
Returns the id of the first child in the <I>node</I>'s list |
| 914 |
of subtrees. If <I>node</I> is a leaf (has no children), |
| 915 |
then <B>-1</B> is returned. |
| 916 |
<P><DT><A NAME="M134"><I>treeName</I> <B>fixed</B> <I>node</I> ?<I>isfixed</I>?</A><DD> |
| 917 |
Get or set the fixed key-fields flag for the node. |
| 918 |
New key-fields can be added to a node only if fixed is 0 (the default) |
| 919 |
Note that copied and restored nodes do not preserve the fixed state. |
| 920 |
<P><DT><A NAME="M135"><I>treeName</I> <B>foreach</B> <I>var tagnode script</I></A><DD> |
| 921 |
Provides a <B><A HREF="../TclCmd/foreach.htm">foreach</A></B> loop for tree. For |
| 922 |
each node in <I>tagnode</I> the node-id is assigned to <I>var</I> and then |
| 923 |
<I>script</I> is evaluated. The <I>tagnode</I> is either a tag or a list of |
| 924 |
nodes as described in the section |
| 925 |
above. |
| 926 |
<P><DT><A NAME="M136"><I>treeName</I> <B>get</B> <I>node</I> ?<I>key</I>? ?<I>defaultValue</I>?</A><DD> |
| 927 |
Returns a list of key-value pairs of data for <I>node</I>. If <I>key</I> |
| 928 |
is present, then only the value for that particular data field is |
| 929 |
returned. It's normally an error if <I>node</I> does not contain the |
| 930 |
data field <I>key</I>. But if you provide a <I>defaultValue</I> |
| 931 |
argument, this value is returned instead (<I>node</I> will still not |
| 932 |
contain <I>key</I>). This feature can be used to access a data field of |
| 933 |
<I>node</I> without first testing if it exists. This operation may |
| 934 |
trigger <B><A HREF="../TclCmd/read.htm">read</A></B> data traces. |
| 935 |
<P><DT><A NAME="M137"><I>treeName</I> <B>incr</B> <I>node key</I> ?<I>amount</I>?</A><DD> |
| 936 |
Increment value by 1 or given <I>amount</I> and return the value. |
| 937 |
The incr operation normally tries to use integers, |
| 938 |
but uses doubles when one of |
| 939 |
value or <I>amount</I> is a double. |
| 940 |
<P><DT><A NAME="M138"><I>treeName</I> <B>incri</B> <I>tagnode key</I> ?<I>amount</I>?</A><DD> |
| 941 |
The same as <B><A HREF="../TclCmd/incr.htm">incr</A></B> but accepts a multi-node tag and an |
| 942 |
undefined key will be initialized to 0. Returns the number of nodes |
| 943 |
updated. |
| 944 |
<P><DT><A NAME="M139"><I>treeName</I> <B>index</B> <I>node</I></A><DD> |
| 945 |
Returns the id of <I>node</I>. In addition |
| 946 |
to standard node id form, |
| 947 |
<I>node</I> can also be a path (a list of labels from the root) as returned |
| 948 |
by the <B>path</B> command. |
| 949 |
If <I>node</I> is invalid, then <B>-1</B> is returned. |
| 950 |
<P><DT><A NAME="M140"><I>treeName</I> <B>insert</B> <I>parent</I> ?<I>switches</I>?</A><DD> |
| 951 |
Inserts a new node into parent node <I>parent</I>. |
| 952 |
The <I>parent</I> can be the keyword <B>end</B> to mean the root. |
| 953 |
The id of the new node is returned. The following switches |
| 954 |
are available: |
| 955 |
<P> |
| 956 |
<DL class="tree operations"> |
| 957 |
<DT><A NAME="M141"><B>-after</B> <I>child</I></A><DD> |
| 958 |
Position <I>node</I> after <I>child</I>. The node <I>child</I> must be a |
| 959 |
child of <I>parent</I>. |
| 960 |
<P><DT><A NAME="M142"><B>-at</B> <I>number</I></A><DD> |
| 961 |
Inserts the node into <I>parent</I>'s list of children at |
| 962 |
position <I>number</I>. The default is to append. |
| 963 |
<P><DT><A NAME="M143"><B>-before</B> <I>child</I></A><DD> |
| 964 |
Position <I>node</I> before <I>child</I>. The node <I>child</I> must be a |
| 965 |
child of <I>parent</I>. |
| 966 |
<P><DT><A NAME="M144"><B>-data</B> <I>dataList</I></A><DD> |
| 967 |
Sets the value for each data field in <I>dataList</I> for the |
| 968 |
new node. <I>DataList</I> is a list of key-value pairs. |
| 969 |
May not be used in conjuction with <B>-names</B> or <B>-values</B>. |
| 970 |
<P><DT><A NAME="M145"><B>-fixed</B> <I>bool</I></A><DD> |
| 971 |
If <I>bool</I> is 1, set <B>fixed</B> field mode after initializing |
| 972 |
the key/value pairs from <B>-data</B>. |
| 973 |
This disallows creation of new key fields |
| 974 |
after the node is created. |
| 975 |
If not given, uses the tree default for fixed. |
| 976 |
<P><DT><A NAME="M146"><B>-label</B> <I>string</I></A><DD> |
| 977 |
Designates the labels of the node as <I>string</I>. By default, nodes |
| 978 |
are labeled as <B>0</B>, <B>1</B>, etc. |
| 979 |
<P><DT><A NAME="M147"><B>-names</B> <I>nameList</I></A><DD> |
| 980 |
The names for the data fields. This must have the same length as |
| 981 |
<B>-values</B>, and may not be used in conjuction with <B>-data</B>. |
| 982 |
<P><DT><A NAME="M148"><B>-node</B> <I>id</I></A><DD> |
| 983 |
Designates the id for the node. Normally new ids are automatically |
| 984 |
generated. This allows you to create a node with a specific id. |
| 985 |
It is an error if the id is already used by another node in the tree. |
| 986 |
<P><DT><A NAME="M149"><B>-pretags</B> <I>tagList</I></A><DD> |
| 987 |
Adds each tag in <I>tagList</I> to the new node, before |
| 988 |
data is added. Unlike <B>-tags</B>, traces on these tags |
| 989 |
will fire on key data during the insert. |
| 990 |
<P><DT><A NAME="M150"><B>-tags</B> <I>tagList</I></A><DD> |
| 991 |
Adds each tag in <I>tagList</I> to the new node. <I>TagList</I> is a list |
| 992 |
of tags, so be careful if a tag has embedded space. |
| 993 |
<P><DT><A NAME="M151"><B>-values</B> <I>valueList</I></A><DD> |
| 994 |
The values for the data fields. This must have the same length as |
| 995 |
<B>-values</B>, and may not be used in conjuction with <B>-data</B>. |
| 996 |
<P></DL> |
| 997 |
<P><DT><A NAME="M152"><I>treeName</I> <B>is</B> <I>property</I> <I>args</I></A><DD> |
| 998 |
Indicates the property of a node. Both <I>property</I> and <I>args</I> |
| 999 |
determine the property being tested. Returns <B>1</B> if true and |
| 1000 |
<B>0</B> otherwise. The following <I>property</I> and <I>args</I> |
| 1001 |
are valid: |
| 1002 |
<P> |
| 1003 |
<DL class="tree operations"> |
| 1004 |
<DT><A NAME="M153"><B>ancestor</B> <I>node1</I> <I>node2</I></A><DD> |
| 1005 |
Indicates if <I>node1</I> is an ancestor of <I>node2</I>. |
| 1006 |
<P><DT><A NAME="M154"><B>before</B> <I>node1</I> <I>node2</I></A><DD> |
| 1007 |
Indicates if <I>node1</I> is before <I>node2</I> in depth first traversal. |
| 1008 |
<P><DT><A NAME="M155"><B>leaf</B> <I>node</I></A><DD> |
| 1009 |
Indicates if <I>node</I> is a leaf (it has no subtrees). |
| 1010 |
<P><DT><A NAME="M156"><B>root</B> <I>node</I></A><DD> |
| 1011 |
Indicates if <I>node</I> is the designated root. This can be changed |
| 1012 |
by the <B>root</B> operation. |
| 1013 |
<P></DL> |
| 1014 |
<P><DT><A NAME="M157"><I>treeName</I> <B>ismodified</B> ?<I>nodeOrTag</I>? ?<I>isflag</I>?</A><DD> |
| 1015 |
Get or set modified state for the tree or nodes. |
| 1016 |
With no args returns modified state for tree. |
| 1017 |
With one args returns modified state for a node. |
| 1018 |
With two args set modified state for one or more nodes. |
| 1019 |
In the last case, where ?<I>nodeOrTag</I>? is the tag <B>all</B>, |
| 1020 |
the state for the tree is also set. |
| 1021 |
<P> |
| 1022 |
Newly created nodes |
| 1023 |
are always considered to be modified until explicitly |
| 1024 |
cleared. After clearing, subsequent updates to keys or tags |
| 1025 |
will toggle the node (and tree) modified again. |
| 1026 |
<P><DT><A NAME="M158"><I>treeName</I> <B>keys</B> <I>node</I> ?<I>tagnode ...</I>?</A><DD> |
| 1027 |
Return list of unique keys for all of the given nodes in <I>tagnode</I>. |
| 1028 |
Accepts nodes and tags or all. |
| 1029 |
<P><DT><A NAME="M159"><I>treeName</I> <B>label</B> <I>node</I> ?<I>newLabel</I>?</A><DD> |
| 1030 |
Returns the label of the node designated by <I>node</I>. If <I>newLabel</I> |
| 1031 |
is present, the node is relabeled using it as the new label. |
| 1032 |
<P><DT><A NAME="M160"><I>treeName</I> <B>lappend</B> <I>node key</I> <I>value</I> ?<I>value ...</I>?</A><DD> |
| 1033 |
Append one or more list values to node/key value. |
| 1034 |
<P><DT><A NAME="M161"><I>treeName</I> <B>lappendi</B> <I>tagnode key</I> <I>value</I> ?<I>value ...</I>?</A><DD> |
| 1035 |
The same as <B><A HREF="../TclCmd/lappend.htm">lappend</A></B> but accepts a multi-node tag and an |
| 1036 |
undefined key will be initialized to {}. Returns the number of nodes |
| 1037 |
updated. |
| 1038 |
<P><DT><A NAME="M162"><I>treeName</I> <B>lastchild</B> <I>node</I></A><DD> |
| 1039 |
Returns the id of the last child in the <I>node</I>'s list |
| 1040 |
of subtrees. If <I>node</I> is a leaf (has no children), |
| 1041 |
then <B>-1</B> is returned. |
| 1042 |
<P><DT><A NAME="M163"><I>treeName</I> <B>modify</B> <I>tagnode</I> <I>key value</I> ?<I>key value</I>...?</A><DD> |
| 1043 |
Update one or more fields in one or more nodes in <I>tagnode</I>. |
| 1044 |
As with <B><A HREF="../TclCmd/set.htm">set</A></B>, <I>node</I> |
| 1045 |
can be a tag referring to multiple nodes. |
| 1046 |
This is identical to <B><A HREF="../TclCmd/set.htm">set</A></B>, except an error is thrown if |
| 1047 |
any of the key fields do not exist. |
| 1048 |
Despite the error, all nodes that do have said fields get updated. |
| 1049 |
For modifying a single node, see <B><A HREF="../TclCmd/update.htm">update</A></B>. |
| 1050 |
<P><DT><A NAME="M164"><I>treeName</I> <B>move</B> <I>node</I> <I>newParent</I> ?<I>switches</I>?</A><DD> |
| 1051 |
Moves <I>node</I> into <I>newParent</I>. <I>Node</I> is appended to the |
| 1052 |
list children of <I>newParent</I>. <I>Node</I> can not be an ancestor |
| 1053 |
of <I>newParent</I>. The valid flags for <I>switches</I> are described below. |
| 1054 |
<P> |
| 1055 |
<DL class="tree operations"> |
| 1056 |
<DT><A NAME="M165"><B>-after</B> <I>child</I></A><DD> |
| 1057 |
Position <I>node</I> after <I>child</I>. The node <I>child</I> must be a |
| 1058 |
child of <I>newParent</I>. |
| 1059 |
<P><DT><A NAME="M166"><B>-at</B> <I>number</I></A><DD> |
| 1060 |
Inserts <I>node</I> into <I>parent</I>'s list of children at |
| 1061 |
position <I>number</I>. The default is to append the node. |
| 1062 |
<P><DT><A NAME="M167"><B>-before</B> <I>child</I></A><DD> |
| 1063 |
Position <I>node</I> before <I>child</I>. The node <I>child</I> must be a |
| 1064 |
child of <I>newParent</I>. |
| 1065 |
<P></DL> |
| 1066 |
<P><DT><A NAME="M168"><I>treeName</I> <B>names</B> <I>node</I> ?<I>key</I>?</A><DD> |
| 1067 |
Return key names for <I>node</I>. If a key is given, |
| 1068 |
attempts to return ARRAY fields (see ARRAY SUB-FIELDS). |
| 1069 |
An error is thrown if the convert to array fails (ie. list-length is odd). |
| 1070 |
The <B>type</B> command can be used to query the type. |
| 1071 |
See also <B>values</B>. |
| 1072 |
<P><DT><A NAME="M169"><I>treeName</I> <B>next</B> <I>node</I></A><DD> |
| 1073 |
Returns the next node from <I>node</I> in a preorder traversal. |
| 1074 |
If <I>node</I> is the last node in the tree, |
| 1075 |
then <B>-1</B> is returned. |
| 1076 |
<P><DT><A NAME="M170"><I>treeName</I> <B>nextsibling</B> <I>node</I></A><DD> |
| 1077 |
Returns the node representing the next subtree from <I>node</I> |
| 1078 |
in its parent's list of children. If <I>node</I> is the last child, |
| 1079 |
then <B>-1</B> is returned. |
| 1080 |
<P><DT><A NAME="M171"><I>treeName</I> <B>nodeseq</B> ?<I>start</I>?</A><DD> |
| 1081 |
Get or set the <I>start</I> sequence number for subsequent |
| 1082 |
node insertions not using <B>-node</B>. The default is 0. |
| 1083 |
<P><DT><A NAME="M172"><I>treeName</I> <B>notify</B> <I>args</I></A><DD> |
| 1084 |
Manages notification events that indicate that the tree structure has |
| 1085 |
been changed. |
| 1086 |
See the |
| 1087 |
section below. |
| 1088 |
<P><DT><A NAME="M173"><I>treeName</I> <B>oldvalue</B> ?<I>newvalue</I>?</A><DD> |
| 1089 |
Return the value from before the last (untraced) change operation. |
| 1090 |
This is used primarly by write traces wishing to |
| 1091 |
restore a key to it's pre-write value (eg. read-only variables). |
| 1092 |
The oldvalue is saved internally everytime a change operation occurs |
| 1093 |
to a key value by deferring its deallocation. |
| 1094 |
Changes made during node traces do not affect oldvalue. |
| 1095 |
<P> |
| 1096 |
If <I>newvalue</I> is provided, the current value of oldvalue is |
| 1097 |
discarded and replaced. This is useful really only for releasing large objects. |
| 1098 |
<P><DT><A NAME="M174"><I>treeName</I> <B>parent</B> <I>node</I></A><DD> |
| 1099 |
Returns the parent node of <I>node</I>. If <I>node</I> is the root |
| 1100 |
of the tree, |
| 1101 |
then <B>-1</B> is returned. |
| 1102 |
<P><DT><A NAME="M175"><I>treeName</I> <B>path</B> <I>node</I> ?<I>delim</I>? ?<I>prefix</I>?</A><DD> |
| 1103 |
Returns the full path (from root) of <I>node</I> using the node labels. |
| 1104 |
If <I>delim</I> is not specified, the result is a list. |
| 1105 |
Otherwise, the result is a string starting with <I>prefix</I> and |
| 1106 |
each element of the path separated by <I>delim</I>. |
| 1107 |
This latter form is useful for building tags like: <B>.able.baker</B> |
| 1108 |
<P><DT><A NAME="M176"><I>treeName</I> <B>position</B> ?<B>-sort</B>? ?<B>-format</B> <I>ftype</I>? <I>node</I> ?<I>node</I> ...?</A><DD> |
| 1109 |
Returns the position of the node(s) in its parent's list of children. |
| 1110 |
Positions are numbered from 0. |
| 1111 |
The position of the root node is always 0. |
| 1112 |
The value of <I>ftype</I> is one of: |
| 1113 |
<B>position parent-at-position id+position id+parent-at-position</B>. |
| 1114 |
<P><DT><A NAME="M177"><I>treeName</I> <B>previous</B> <I>node</I></A><DD> |
| 1115 |
Returns the previous node from <I>node</I> in a preorder traversal. |
| 1116 |
If <I>node</I> is the root of the tree, |
| 1117 |
then <B>-1</B> is returned. |
| 1118 |
<P><DT><A NAME="M178"><I>treeName</I> <B>prevsibling</B> <I>node</I></A><DD> |
| 1119 |
Returns the node representing the previous subtree from <I>node</I> |
| 1120 |
in its parent's list of children. If <I>node</I> is the first child, |
| 1121 |
then <B>-1</B> is returned. |
| 1122 |
<P><DT><A NAME="M179"><I>treeName</I> <B>restore</B> <I>node</I> <I>switches</I></A><DD> |
| 1123 |
Performs the inverse function of the <B>dump</B> operation, restoring |
| 1124 |
nodes to the tree. The format of the input data is exactly what is |
| 1125 |
returned by the <B>dump</B> operation. It's a list containing information |
| 1126 |
for each node to be restored. The information consists of 1) the relative |
| 1127 |
path of the node, 2) a sublist of key value pairs representing the |
| 1128 |
node's data, 3) a list of tags for the node, and 4) the label. |
| 1129 |
Nodes are created |
| 1130 |
starting from <I>node</I>. Nodes can be listed in any order. If a node's |
| 1131 |
path describes ancestor nodes that do not already exist, they are |
| 1132 |
automatically created. |
| 1133 |
<P> |
| 1134 |
The valid <I>switches</I> are listed below. Exactly one |
| 1135 |
of <B>-channel</B>, <B>-file</B> or <B>-data</B> must be specified. |
| 1136 |
<P> |
| 1137 |
<DL class="tree operations"> |
| 1138 |
<DT><A NAME="M180"><B>-addtags</B></A><DD> |
| 1139 |
List of tags to add to each node restored node. |
| 1140 |
<P><DT><A NAME="M181"><B>-channel </B><I>chan</I></A><DD> |
| 1141 |
Obtain data from from the given channel <I>chan</I>. |
| 1142 |
The channel is not closed afterwards. |
| 1143 |
<P><DT><A NAME="M182"><B>-data </B><I>string</I></A><DD> |
| 1144 |
Data input is from the given <I>string</I>. |
| 1145 |
<P><DT><A NAME="M183"><B>-file </B><I>fileName</I></A><DD> |
| 1146 |
Obtain data from from the file. |
| 1147 |
<I>fileName</I>. This options is unsupported in a safe interp. |
| 1148 |
<P><DT><A NAME="M184"><B>-keys </B><I>list</I></A><DD> |
| 1149 |
A list of patterns of matching keys to be restored. |
| 1150 |
<P><DT><A NAME="M185"><B>-skipkeys </B><I>list</I></A><DD> |
| 1151 |
A list of patterns of matching keys not to be restored. |
| 1152 |
<P><DT><A NAME="M186"><B>-tag </B><I>pattern</I></A><DD> |
| 1153 |
A pattern match for tags to include in a node restore. |
| 1154 |
<P><DT><A NAME="M187"><B>-skiptag </B><I>pattern</I></A><DD> |
| 1155 |
A pattern match for tags to not include in a node restore. |
| 1156 |
<P><DT><A NAME="M188"><B>-notags</B></A><DD> |
| 1157 |
Do not restore any tags |
| 1158 |
<P><DT><A NAME="M189"><B>-overwrite</B></A><DD> |
| 1159 |
Overwrite nodes that already exist. Normally nodes are always |
| 1160 |
created, even if there already exists a node by the same name. This |
| 1161 |
switch indicates to overwrite existing node's data fields. |
| 1162 |
<P></DL> |
| 1163 |
<P><DT><A NAME="M190"><I>treeName</I> <B>root</B> ?<I>node</I>?</A><DD> |
| 1164 |
Returns the id of the root node. Normally this is node <B>0</B>. If |
| 1165 |
a <I>node</I> argument is provided, it will become the new root of the |
| 1166 |
tree. This lets you temporarily work within a subset of the tree. |
| 1167 |
Changing root affects operations such as <B><A HREF="../TclCmd/next.htm">next</A></B>, <B>path</B>, |
| 1168 |
<B>previous</B>, etc. |
| 1169 |
<P><DT><A NAME="M191"><I>treeName</I> <B>set</B> <I>tagnode</I> <I>key value</I> ?<I>key value</I>...?</A><DD> |
| 1170 |
Sets one or more data fields in <I>node</I>. <I>tagode</I> may |
| 1171 |
be a tag that represents several nodes and a count of the number |
| 1172 |
of nodes updated is returned. |
| 1173 |
<I>Key</I> is the |
| 1174 |
name of the data field to be set, or an array-like reference such as <B>field(subkey)</B>. |
| 1175 |
See the |
| 1176 |
section below. <I>Value</I> is the respective keys value. |
| 1177 |
The <I>Key</I> will be created if it does not exists (see <B>modify</B>). |
| 1178 |
<P> |
| 1179 |
The set operation triggers <B>write</B> and <B>create</B> data traces. |
| 1180 |
<P><DT><A NAME="M192"><I>treeName</I> <B>size</B> <I>node</I></A><DD> |
| 1181 |
Returns the number of nodes in the subtree. This includes the node |
| 1182 |
and all its descendants. The size of a leaf node is 1. |
| 1183 |
<P><DT><A NAME="M193"><I>treeName</I> <B>sort</B> <I>node</I> ?<I>switches</I>?</A><DD> |
| 1184 |
Return nodes in sorted order. |
| 1185 |
<P> |
| 1186 |
<DL class="tree operations"> |
| 1187 |
<DT><A NAME="M194"><B>-ascii</B></A><DD> |
| 1188 |
Compare strings using the ASCII collation order. |
| 1189 |
<P><DT><A NAME="M195"><B>-command</B> <I>string</I></A><DD> |
| 1190 |
Use command <I>string</I> as a comparison command. To compare two |
| 1191 |
elements, evaluate a Tcl script consisting of command with the five |
| 1192 |
elements appended as additional arguments: |
| 1193 |
<I>the tree, node1, node1, label1, label2</I>. |
| 1194 |
The script should return |
| 1195 |
an integer less than, equal to, or greater than zero if the first |
| 1196 |
element is to be considered less than, equal to, or greater than the |
| 1197 |
second, respectively. |
| 1198 |
<P><DT><A NAME="M196"><B>-decreasing</B></A><DD> |
| 1199 |
Sort in decreasing order (largest items come first). |
| 1200 |
<P><DT><A NAME="M197"><B>-dictionary</B></A><DD> |
| 1201 |
Compare strings using a dictionary-style comparison. This is the same |
| 1202 |
as <B>-ascii</B> except (a) case is ignored except as a tie-breaker and (b) |
| 1203 |
if two strings contain embedded numbers, the numbers compare as integers, not |
| 1204 |
characters. For example, in <B>-dictionary</B> mode, bigBoy sorts between |
| 1205 |
bigbang and bigboy, and x10y sorts between x9y and x11y. |
| 1206 |
<P><DT><A NAME="M198"><B>-integer</B></A><DD> |
| 1207 |
Compare the nodes as integers. |
| 1208 |
<P><DT><A NAME="M199"><B>-key</B> <I>string</I></A><DD> |
| 1209 |
Sort based upon the node's data field keyed by <I>string</I>. Normally |
| 1210 |
nodes are sorted according to their label. |
| 1211 |
label. |
| 1212 |
<P><DT><A NAME="M200"><B>-real</B></A><DD> |
| 1213 |
Compare the nodes as real numbers. |
| 1214 |
<P><DT><A NAME="M201"><B>-recurse</B></A><DD> |
| 1215 |
Recursively sort the entire subtree rooted at <I>node</I>. |
| 1216 |
<P><DT><A NAME="M202"><B>-reorder</B></A><DD> |
| 1217 |
Recursively sort subtrees for each node. <B>Warning</B>. Unlike |
| 1218 |
the normal flat sort, where a list of nodes is returned, this will |
| 1219 |
reorder the tree. |
| 1220 |
<P><DT><A NAME="M203"><B>-usepath</B></A><DD> |
| 1221 |
Compare the full path of each node. The default is to compare only the node |
| 1222 |
label. |
| 1223 |
<P></DL> |
| 1224 |
<P><DT><A NAME="M204"><I>treeName</I> <B>sqlload</B> ?<I>switches</I>? <I>dbhfile</I> <I>sqlstmt</I></A><DD> |
| 1225 |
Load tree with the results of evaling the SQL in <I>sqlstmt</I> using |
| 1226 |
<I>dbhfile</I>. |
| 1227 |
The evaluated SQL creates one tree-node per row result. |
| 1228 |
The returned value is the number of rows loaded. |
| 1229 |
<I>Dbhfile</I> is either an <B>sqlite3</B> database handle, |
| 1230 |
or an <B>sqlite3</B> file. |
| 1231 |
<P> |
| 1232 |
The <B>sqlload</B> command can populate a tree with 10k nodes |
| 1233 |
about 7 times faster than <B>sqlite3 eval</B>. |
| 1234 |
It also preserves NULL values |
| 1235 |
and object types (eg. int or double) used internally |
| 1236 |
by sqlite. This eliminates later reconversion within tree. |
| 1237 |
See the |
| 1238 |
below. |
| 1239 |
<P> |
| 1240 |
The following switches are available: |
| 1241 |
<P> |
| 1242 |
<DL class="tree operations"> |
| 1243 |
<DT><A NAME="M205"><B>-addtags </B><I>taglist</I></A><DD> |
| 1244 |
The tags in <I>taglist</I> to add to each inserted node. |
| 1245 |
<P><DT><A NAME="M206"><B>-at </B><I>num</I></A><DD> |
| 1246 |
Where to insert into parents list of children. |
| 1247 |
Default is -1, meaning append. |
| 1248 |
<P><DT><A NAME="M207"><B>-fixed</B></A><DD> |
| 1249 |
Set the <B>fixed</B> flag to disallow new keys after creation. |
| 1250 |
<P><DT><A NAME="M208"><B>-key </B><I>name</I></A><DD> |
| 1251 |
Store the entire result in the key <I>name</I> instead |
| 1252 |
of creating one key per column. |
| 1253 |
Array notation can be used to then access column results. |
| 1254 |
This is more efficent as it initially stores just one |
| 1255 |
object per row. Conversion to an array |
| 1256 |
is at the first array access (if that occurs). |
| 1257 |
<P><DT><A NAME="M209"><B>-labelcol </B><I>column</I></A><DD> |
| 1258 |
The value of <I>column</I> is used as the label. |
| 1259 |
By default the label is the node id. |
| 1260 |
<P><DT><A NAME="M210"><B>-maprowid </B><I>num</I></A><DD> |
| 1261 |
This option maps the node id to the rowid plus the constant <I>num</I>. |
| 1262 |
The key for <B>rowid</B> will also not be created. |
| 1263 |
This is applicable only if <B>rowid</B> is returned in the result-set |
| 1264 |
of <I>sqlstmt</I>. |
| 1265 |
If <B>rowid</B> is not in the result set, this option is ignored. |
| 1266 |
If mapping fails (because the tree already contains a requested node) |
| 1267 |
the load will abort at that point |
| 1268 |
with an error. Note that <I>num</I> must be >= 1 since sqlite |
| 1269 |
rowids start from 0, but the root node of the tree uses the node-id 0. |
| 1270 |
<P><DT><A NAME="M211"><B>-max </B><I>num</I></A><DD> |
| 1271 |
The maximum number of rows to return. The default is 100,000. |
| 1272 |
Note that SQL queries on large tables should probably always use LIMIT. |
| 1273 |
<P><DT><A NAME="M212"><B>-nullvalue </B><I>string</I></A><DD> |
| 1274 |
Define value to use for null values. The default is no value, |
| 1275 |
meaning do not set key if value is null. |
| 1276 |
Note this is different from the sqlite Tcl extension which uses |
| 1277 |
an empty string for NULL. |
| 1278 |
<P><DT><A NAME="M213"><B>-parent </B><I>string</I></A><DD> |
| 1279 |
The node where results are |
| 1280 |
inserted as child nodes. The default is the tree root. |
| 1281 |
<P><DT><A NAME="M214"><B>-pathcol </B><I>column</I></A><DD> |
| 1282 |
Name of column containing the full path where node is to be created. |
| 1283 |
This works like <B>-treecols</B>, but uses a singl columns. |
| 1284 |
<P><DT><A NAME="M215"><B>-skipcols </B><I>columns</I></A><DD> |
| 1285 |
The given <I>columns</I> are not to be added as keys. This is useful mostly |
| 1286 |
in conjuction with <B>-tagcol</B>, <B>-labelcol</B>, <B>-pathcol</B>. |
| 1287 |
<P><DT><A NAME="M216"><B>-tagcol </B><I>column</I></A><DD> |
| 1288 |
The value of <I>column</I> is added as a tag. |
| 1289 |
<P><DT><A NAME="M217"><B>-treecols </B><I>columns</I></A><DD> |
| 1290 |
Columns whose values concatenated |
| 1291 |
give the path of where node is to be created. |
| 1292 |
This works like <B>-pathcol</B>, but uses multiple columns. |
| 1293 |
<P></DL> |
| 1294 |
<P><DT><A NAME="M218"><I>treeName</I> <B>sum</B> ?<I>switches</I>? <I>tagnode key</I> ?<I>key ...</I>?</A><DD> |
| 1295 |
Add values in key fields for all <I>tagnode</I> and return the sum. |
| 1296 |
Values that are not doubles (or integer) are ignored. |
| 1297 |
<P> |
| 1298 |
<DL class="tree operations"> |
| 1299 |
<DT><A NAME="M219"><B>-diff</B><I> value</I></A><DD> |
| 1300 |
Double value difference to ignore and not do update for <B>-runtotal</B>. |
| 1301 |
This is unused when using <B>-int</B>. |
| 1302 |
<P><DT><A NAME="M220"><B>-force</B></A><DD> |
| 1303 |
Force update <B>-runtotal</B> even if value was unchanged. |
| 1304 |
Normally, a check is made to avoid updating unchanged values. |
| 1305 |
<P><DT><A NAME="M221"><B>-int</B></A><DD> |
| 1306 |
Use and accept only integer values. |
| 1307 |
<P><DT><A NAME="M222"><B>-runtotal </B><I>key</I></A><DD> |
| 1308 |
Place running total in the given key field (if changed). |
| 1309 |
<P><DT><A NAME="M223"><B>-start </B><I>num</I></A><DD> |
| 1310 |
The start value for the sum: default is 0. |
| 1311 |
<P></DL> |
| 1312 |
<P><DT><A NAME="M224"><I>treeName</I> <B>supdate</B> <I>node</I> <I>key value</I> ?<I>key value</I>...?</A><DD> |
| 1313 |
Like <B><A HREF="../TclCmd/update.htm">update</A></B>, but with a string comparison |
| 1314 |
to avoid a write if the value has not changed. |
| 1315 |
<P><DT><A NAME="M225"><I>treeName</I> <B>tag</B> <I>args</I></A><DD> |
| 1316 |
Manages tags for the tree object. |
| 1317 |
See the |
| 1318 |
section below. |
| 1319 |
<P><DT><A NAME="M226"><I>treeName</I> <B>trace</B> <I>args</I></A><DD> |
| 1320 |
Manages traces for data fields in the tree object. |
| 1321 |
Traces cause Tcl commands to be executed whenever a data field of a |
| 1322 |
node is created, read, written, or unset. Traces can be set for a |
| 1323 |
specific node or a tag, representing possibly many nodes. |
| 1324 |
See the |
| 1325 |
section below. |
| 1326 |
<P><DT><A NAME="M227"><I>treeName</I> <B>type</B> <I>node</I> <I>key</I></A><DD> |
| 1327 |
Return type of value. This is the introspected type from the Tcl_Obj |
| 1328 |
value passed to set. |
| 1329 |
<P><DT><A NAME="M228"><I>treeName</I> <B>update</B> <I>node</I> <I>key value</I> ?<I>key value</I>...?</A><DD> |
| 1330 |
Like <B>modify</B>, except an error is generated if a tag |
| 1331 |
is used that applies to more than one node. |
| 1332 |
<P><DT><A NAME="M229"><I>treeName</I> <B>unset</B> <I>node</I> <I>key</I>...</A><DD> |
| 1333 |
Removes one or more data fields from <I>node</I>. <I>Node</I> may |
| 1334 |
be a tag that represents several nodes. <I>Key</I> is the |
| 1335 |
name of the data field to be removed. It's not an error is |
| 1336 |
<I>node</I> does not contain <I>key</I>. |
| 1337 |
A count of the number of nodes unset is returned. |
| 1338 |
This operation may trigger <B><A HREF="../TclCmd/unset.htm">unset</A></B> data traces. |
| 1339 |
<P><DT><A NAME="M230"><I>treeName</I> <B>values</B> <I>node</I> ?<I>key</I>? ?<I>withnames</I>?</A><DD> |
| 1340 |
Return values for <I>node</I>. |
| 1341 |
The values are returned in the same order as the keys |
| 1342 |
returned from <B>names</B>. |
| 1343 |
<P> |
| 1344 |
If a <I>key</I> is given, |
| 1345 |
array values get returned for the <I>key</I> value. |
| 1346 |
If <I>withname</I> is <B>True</B>, then key |
| 1347 |
names are also returned with the values. This differs from <B>get</B> |
| 1348 |
in that the result is a true Tcl list object, not an array object. |
| 1349 |
If subsequently using an array value in a list context, |
| 1350 |
this can be more efficient by |
| 1351 |
avoiding a split on string representations. |
| 1352 |
<P><DT><A NAME="M231"><I>treeName</I> <B>vecdump</B> <I>vector</I> <I>key</I> ?<I>tagnode</I>?</A><DD> |
| 1353 |
Dump key field to a vector. With no <I>tagnode</I>, dumps every node |
| 1354 |
to the 1-1 corresponding vector index. With <I>tag</I> dumps |
| 1355 |
nodes to consequetive vector elements. |
| 1356 |
<P><DT><A NAME="M232"><I>treeName</I> <B>vecload</B> <I>vector</I> <I>key</I> ?<I>tagnode</I>?</A><DD> |
| 1357 |
Loads key field from a vector. With no <I>tagnode</I>, loads every node |
| 1358 |
from the 1-1 corresponding vector index. With <I>tag</I> loads |
| 1359 |
nodes from consequetive vector elements. |
| 1360 |
<P><DT><A NAME="M233"><I>treeName</I> <B>with</B> ?<I>switch</I>? <I>tagnode script</I></A><DD> |
| 1361 |
For each node in <I>tagnode</I>, |
| 1362 |
evaluate the <I>script</I> after assigning key values to |
| 1363 |
elements of the array <I>variable</I>. |
| 1364 |
The <B>-keys</B> limits which keys may be assigned. |
| 1365 |
If <I>script</I> completes normally, |
| 1366 |
and any of the key values change in the <I>variable</I>, then the |
| 1367 |
updates are reflected back into the key values |
| 1368 |
(unless <B>-noupdate</B> is used). |
| 1369 |
Unsetting a variable key |
| 1370 |
will cause that change to be ignored. Setting a new element in the |
| 1371 |
variable has no effect. |
| 1372 |
<P> |
| 1373 |
Doing a <B><A HREF="../TclCmd/return.htm">return</A></B>, <B><A HREF="../TclCmd/break.htm">break</A></B>, or <B><A HREF="../TclCmd/continue.htm">continue</A></B> inside |
| 1374 |
<I>script</I> will still cause updates to copy back, but |
| 1375 |
processing will stop and (unless <B>-break</B> is used) |
| 1376 |
the return code will become the return code to the caller. |
| 1377 |
This means that a <B><A HREF="../TclCmd/break.htm">break</A></B>, <B><A HREF="../TclCmd/continue.htm">continue</A></B>, and |
| 1378 |
<B><A HREF="../TclCmd/return.htm">return</A></B> will propagate up through |
| 1379 |
multiple nested <B>with</B> statements to the |
| 1380 |
to an enclosing <B><A HREF="../TclCmd/foreach.htm">foreach</A></B>, <B><A HREF="../TclCmd/while.htm">while</A></B>, etc. |
| 1381 |
But <B>-break</B> can be used to change this and make <B>with</B> act |
| 1382 |
like a <B><A HREF="../TclCmd/foreach.htm">foreach</A></B> loop. |
| 1383 |
<P> |
| 1384 |
If <B>-keys</B> is not used, the list of key names will be |
| 1385 |
stored in <I>variable(*)</I> and the node id |
| 1386 |
stored in <I>variable(#)</I> (but this can be overwritten by a key of that name). |
| 1387 |
By default, the array is not cleaned up before or after each execution. |
| 1388 |
However, if <B>-unset</B> is used, the array is unset at the start of each |
| 1389 |
iteration. |
| 1390 |
<P> |
| 1391 |
If <B>-array</B> is used, <B>with</B> operates on the keys of an array |
| 1392 |
instead. |
| 1393 |
<P> |
| 1394 |
Upon normal completion, the number of times <I>script</I> |
| 1395 |
was evaluated is returned. |
| 1396 |
<P> |
| 1397 |
The valid switches are listed below: |
| 1398 |
<P> |
| 1399 |
<DL class="tree operations"> |
| 1400 |
<DT><A NAME="M234"><B>-array</B> <I>key</I></A><DD> |
| 1401 |
Specifies a |
| 1402 |
single key that is to be treated as an array. |
| 1403 |
The fields of the array for that one key are then used |
| 1404 |
(instead of keys of the whole node). |
| 1405 |
This changes the meaning of <B>-keys</B> to be the |
| 1406 |
keys of the array rather than the keys of the node. |
| 1407 |
If a key value can not be converted to an array, |
| 1408 |
an error will occur. |
| 1409 |
<P><DT><A NAME="M235"><B>-break</B></A><DD> |
| 1410 |
Treat <B><A HREF="../TclCmd/break.htm">break</A></B> and <B><A HREF="../TclCmd/continue.htm">continue</A></B> like <B><A HREF="../TclCmd/foreach.htm">foreach</A></B> does |
| 1411 |
rather than just passing them up to the enclosing script body. |
| 1412 |
<P><DT><A NAME="M236"><B>-keys</B> <I>keylist</I></A><DD> |
| 1413 |
Copy only the named keys and do not set (*) or (#). |
| 1414 |
<P><DT><A NAME="M237"><B>-noupdate</B></A><DD> |
| 1415 |
Forget changes to array variables and |
| 1416 |
do not copy back changes. |
| 1417 |
<P><DT><A NAME="M238"><B>-unset</B></A><DD> |
| 1418 |
Unset the array variable at the begin of each evaluation. |
| 1419 |
<P></DL> |
| 1420 |
<P></DL> |
| 1421 |
<H3><A NAME="M239">ARRAY SUB-FIELDS</A></H3> |
| 1422 |
Individual data fields of a node support array-like subfield access. |
| 1423 |
This works somewhat like Tcls new <B><A HREF="../TclCmd/dict.htm">dict</A></B> command, except tree uses |
| 1424 |
the familiar array notation for <B>key</B> fields. Here is an example: |
| 1425 |
<PRE>set t [tree create] |
| 1426 |
set n [$t insert 0 -data {a 1 b 2 c "x 9 y 8 z 7"}] |
| 1427 |
puts [$t get $n]; # a 1 b 2 c {x 9 y 8 z 7} |
| 1428 |
puts [$t get $n c]; # x 9 y 8 z 7 |
| 1429 |
puts [$t get $n c(y)]; # 8 |
| 1430 |
$t update $n c(y) 8.6 |
| 1431 |
puts [$t get $n c]; # x 9 y 8.6 z 7 |
| 1432 |
$t unset $n c(y) |
| 1433 |
puts [$t get $n c]; # x 9 z 7 |
| 1434 |
$t set $n d 10</PRE> |
| 1435 |
Using incr or update on a non-existant subfield generates an error. |
| 1436 |
Using the <B>type</B> command on such a field returns <I>array</I>. |
| 1437 |
Note that traced operations on arrays trigger on the key value |
| 1438 |
and not individual array elements. |
| 1439 |
<H3><A NAME="M240">TAG OPERATIONS</A></H3> |
| 1440 |
Tags are a general means of selecting and marking nodes in the tree. |
| 1441 |
A tag is just a string of characters, and it may take any form except |
| 1442 |
that of an integer. The same tag may be associated with many |
| 1443 |
different nodes. |
| 1444 |
<P> |
| 1445 |
<P> |
| 1446 |
Most tree operations use tags. And several operations let you |
| 1447 |
operate on multiple nodes at once. For example, you can use the |
| 1448 |
<B><A HREF="../TclCmd/set.htm">set</A></B> operation with the tag <B>all</B> to set a data field in |
| 1449 |
for all nodes in the tree. |
| 1450 |
<P> |
| 1451 |
Tags are invoked by the <B>tag</B> operation. The |
| 1452 |
general form is |
| 1453 |
<dl><dd><table border="0"><tr><td><p style="font-size:12px;padding-left:.5em;padding-right:.5em;"><I>treeName</I> <B>tag</B> <I>operation</I> ?<I>arg</I>?...</table></dl> |
| 1454 |
Both <I>operation</I> and its arguments determine the exact behavior of |
| 1455 |
the command. The operations available for tags are listed below. |
| 1456 |
<P> |
| 1457 |
<DL class="tag operations"> |
| 1458 |
<DT><A NAME="M241"><I>treeName</I> <B>tag add</B> <I>string</I> ?<I>node</I>?...</A><DD> |
| 1459 |
Adds the tag <I>string</I> to zero or more nodes. |
| 1460 |
If no nodes are given, just creates the tag. |
| 1461 |
A count of the number of nodes tagged is returned. |
| 1462 |
<P><DT><A NAME="M242"><I>treeName</I> <B>tag delete</B> <I>string</I> <I>node</I>...</A><DD> |
| 1463 |
Remove the tag <I>string</I> from one or more nodes. |
| 1464 |
A count of the number of nodes visited is returned. |
| 1465 |
Calling <B>tag delete</B> with a builtin tag is ignore. |
| 1466 |
<P><DT><A NAME="M243"><I>treeName</I> <B>tag dump</B> <I>tagnode</I> ?<I>switches</I>?</A><DD> |
| 1467 |
Dump the nodes specified by the tag <I>tagnode</I>. |
| 1468 |
<P> |
| 1469 |
The valid <I>switches</I> are listed below. |
| 1470 |
<P> |
| 1471 |
<DL class="tag operations"> |
| 1472 |
<DT><A NAME="M244"><B>-keys </B><I>list</I></A><DD> |
| 1473 |
A list of patterns of matching keys to be dumped. |
| 1474 |
<P><DT><A NAME="M245"><B>-skipkeys </B><I>list</I></A><DD> |
| 1475 |
A list of patterns of matching keys not to be dumped. |
| 1476 |
<P><DT><A NAME="M246"><B>-tag </B><I>pattern</I></A><DD> |
| 1477 |
A pattern match for tags to include in a node dump. |
| 1478 |
<P><DT><A NAME="M247"><B>-skiptag </B><I>pattern</I></A><DD> |
| 1479 |
A pattern match for tags to not include in a node dump. |
| 1480 |
<P><DT><A NAME="M248"><B>-notags</B></A><DD> |
| 1481 |
Do not dump the tags. |
| 1482 |
<P><DT><A NAME="M249"><B>-nopath</B></A><DD> |
| 1483 |
To save space, do not dump the full path for each node. |
| 1484 |
Instead output periods for all but the last path element. |
| 1485 |
Full paths are used only for partial restores. |
| 1486 |
<P></DL> |
| 1487 |
<P><DT><A NAME="M250"><I>treeName</I> <B>tag exists</B> <I>string</I> ?<I>id</I>?</A><DD> |
| 1488 |
If an <I>id</I> is given, return 1 (or 0) if node has (or hasn't) the tag. |
| 1489 |
Otherwise, returns 1 if at least one nodes has tag <I>string</I>. |
| 1490 |
<P><DT><A NAME="M251"><I>treeName</I> <B>tag forget</B> <I>string</I> ?<I>string</I> ...?</A><DD> |
| 1491 |
Removes the tag definition for one or more of <I>string</I>. |
| 1492 |
It's not an error if the tag <I>string</I> does not exist. |
| 1493 |
<P><DT><A NAME="M252"><I>treeName</I> <B>tag lookups</B> ?<I>pattern</I>?</A><DD> |
| 1494 |
Dump a lookup table (dictionary) |
| 1495 |
of nodes-to-tags, or tags-to-nodes if <I>pattern</I> |
| 1496 |
is given. |
| 1497 |
With no arguments, returns a pair list of nodes/tags, |
| 1498 |
for nodes that have tags. |
| 1499 |
With an argument, returns a pair list of tags/nodes. |
| 1500 |
<B>lookups</B> provides efficient bulk processing when dealing with |
| 1501 |
large numbers of nodes and/or tags. |
| 1502 |
<P><DT><A NAME="M253"><I>treeName</I> <B>tag names</B> ?<B>-glob</B>? ?<B>-regexp</B>? ?<B>-nocase</B>? ?<I>node</I>? ?<I>node ...</I>?</A><DD> |
| 1503 |
Returns a list of tags used by the tree. If no <I>node</I> argument |
| 1504 |
is given, returns a list of all known tags. Otherwise, returns |
| 1505 |
the union of the tags used by all given <I>node</I> numbers. |
| 1506 |
Patterns can be used via <B>-glob</B> or <B>-regexp</B>. |
| 1507 |
If <B>-nocase</B> is used, the pattern is expected to be all lower case. |
| 1508 |
<P><DT><A NAME="M254"><I>treeName</I> <B>tag nodes</B> <I>string</I> ?<I>string ...</I>?</A><DD> |
| 1509 |
Returns a list of any nodes that have any of given <I>string</I> tag. If no node |
| 1510 |
is tagged with any of the <I>string</I>, then an empty string is returned. |
| 1511 |
<P></DL> |
| 1512 |
<H3><A NAME="M255">TRACE OPERATIONS</A></H3> |
| 1513 |
Data fields can be traced much like tracing Tcl |
| 1514 |
variables. Data traces cause a Tcl command to be executed whenever |
| 1515 |
data fields are created, read, written, or unset. |
| 1516 |
A trace can apply to one or more nodes. You can trace a specific node |
| 1517 |
by using its id, or a group of nodes by a their tag. |
| 1518 |
Note: operations on arrays trigger only on the key value |
| 1519 |
and not individual array elements. |
| 1520 |
<P> |
| 1521 |
The tree's <B>get</B>, <B><A HREF="../TclCmd/set.htm">set</A></B>, and <B><A HREF="../TclCmd/unset.htm">unset</A></B> operations can |
| 1522 |
trigger various traces. The <B>get</B> operation can cause |
| 1523 |
a <I>read</I> trace to fire. The <B><A HREF="../TclCmd/set.htm">set</A></B> operation causes a <I>write</I> |
| 1524 |
trace to fire. And if the data field is written for the first time, you |
| 1525 |
will also get a <I>create</I> trace. |
| 1526 |
The <B><A HREF="../TclCmd/unset.htm">unset</A></B> operation triggers <I>unset</I> traces. |
| 1527 |
<P> |
| 1528 |
Data traces are invoked by the <B><A HREF="../TclCmd/trace.htm">trace</A></B> |
| 1529 |
operation. The general form is |
| 1530 |
<dl><dd><table border="0"><tr><td><p style="font-size:12px;padding-left:.5em;padding-right:.5em;"><I>treeName</I> <B><A HREF="../TclCmd/trace.htm">trace</A></B> <I>operation</I> ?<I>arg</I>?...</table></dl> |
| 1531 |
Both <I>operation</I> and its arguments determine the exact behavior of |
| 1532 |
the command. The operations available for traces are listed below. |
| 1533 |
<P> |
| 1534 |
<DL class="trace operations"> |
| 1535 |
<DT><A NAME="M256"><I>treeName</I> <B>trace create</B> <I>node</I> <I>key</I> <I>ops</I> <I>command</I> ?-bgerror?</A><DD> |
| 1536 |
Create a trace on data fields (or tags for tag traces) |
| 1537 |
given by the pattern in <I>key</I>. The <I>node</I> argument |
| 1538 |
can be a nodeid, or a tag to refer to multiple nodes eg. <I>all</I>. |
| 1539 |
The return value is an identifier that can |
| 1540 |
be used with "<B><A HREF="../TclCmd/trace.htm">trace info</A></B>" or "<B><A HREF="../TclCmd/trace.htm">trace delete</A></B>". |
| 1541 |
Traces are temporarily disabled while executing <I>command</I> within the trace. |
| 1542 |
<P> |
| 1543 |
<I>Command</I> is a command prefix, to which |
| 1544 |
four arguments are appended before invocation: |
| 1545 |
<I>treeName</I>, <I>nodeid</I>, <I>key</I> and, <I>ops</I>. |
| 1546 |
If an error occurs in <I>command</I> (and <I>-bgerror</I> was not used) |
| 1547 |
the invoking operation will also abort. |
| 1548 |
<P> |
| 1549 |
<I>Ops</I> indicates which operations are of |
| 1550 |
interest. It consists of one or more of the following letters: |
| 1551 |
<P> |
| 1552 |
<DL class="trace operations"> |
| 1553 |
<DT><A NAME="M257"><B>r</B></A><DD> |
| 1554 |
Invoke <I>command</I> whenever <I>key</I> is read. |
| 1555 |
<P><DT><A NAME="M258"><B>w</B></A><DD> |
| 1556 |
Invoke <I>command</I> whenever <I>key</I> is written. |
| 1557 |
<P><DT><A NAME="M259"><B>c</B></A><DD> |
| 1558 |
Invoke <I>command</I> whenever <I>key</I> is created. |
| 1559 |
<P><DT><A NAME="M260"><B>u</B></A><DD> |
| 1560 |
Invoke <I>command</I> whenever <I>key</I> is unset, |
| 1561 |
typically with the <B><A HREF="../TclCmd/unset.htm">unset</A></B> command. |
| 1562 |
to that. |
| 1563 |
<P><DT><A NAME="M261"><B>e</B></A><DD> |
| 1564 |
Invoke <I>command</I> whenever <B>exists</B> is used on an non-existant |
| 1565 |
key. This can be used to populate node key data on demand. |
| 1566 |
<P><DT><A NAME="M262"><B>t</B></A><DD> |
| 1567 |
Invoke <I>command</I> whenever tag <I>key</I> is added to a node. |
| 1568 |
<P><DT><A NAME="M263"><B>m</B></A><DD> |
| 1569 |
Invoke <I>command</I> when tag <I>key</I> gets added to more than one node. |
| 1570 |
This trace can be used to enforce tags that should be on at most one node. |
| 1571 |
It can avoid later errors with tags used in |
| 1572 |
<B>get</B> or other commands not accepting non-unique tags. |
| 1573 |
<P><DT><A NAME="M264"><B>d</B></A><DD> |
| 1574 |
Invoke <I>command</I> whenever tag <I>key</I> is <I>deleted</I> from a node |
| 1575 |
using either <B>tag delete</B> or <B>tag forget</B>. |
| 1576 |
Node deletion will not trigger this trace. |
| 1577 |
<P> |
| 1578 |
<P></DL> |
| 1579 |
<P><DT><A NAME="M265"><I>treeName</I> <B>trace delete</B> <I>traceId</I>...</A><DD> |
| 1580 |
Deletes one of more traces. <I>TraceId</I> is |
| 1581 |
the trace identifier returned by the <B><A HREF="../TclCmd/trace.htm">trace create</A></B> operation. |
| 1582 |
<P><DT><A NAME="M266"><I>treeName</I> <B>trace info</B> <I>traceId</I></A><DD> |
| 1583 |
Returns information about the trace <I>traceId</I>. <I>TraceId</I> |
| 1584 |
is a trace identifier previously returned by the <B><A HREF="../TclCmd/trace.htm">trace create</A></B> operation. |
| 1585 |
It's the same information specified for the <B><A HREF="../TclCmd/trace.htm">trace create</A></B> operation. |
| 1586 |
It consists of the node id or tag, data field key, a string of letters |
| 1587 |
indicating the operations that are traced (it's in the same |
| 1588 |
form as <I>ops</I>) and, the command prefix. |
| 1589 |
<P><DT><A NAME="M267"><I>treeName</I> <B>trace names</B></A><DD> |
| 1590 |
Returns a list of identifers for all the current traces. |
| 1591 |
<P></DL> |
| 1592 |
<H3><A NAME="M268">NOTIFY OPERATIONS</A></H3> |
| 1593 |
Tree objects can be shared among many clients, such as a |
| 1594 |
<B><A HREF="../TclCmd/treeview.htm">treeview</A></B> widget. Any client can create or delete nodes, |
| 1595 |
sorting the tree, etc. You can request to be notified whenever these |
| 1596 |
events occur. Notify events cause Tcl commands to be executed |
| 1597 |
whenever the tree structure is changed. |
| 1598 |
<P> |
| 1599 |
Notifications are handled by the <B>notify</B> operation. The |
| 1600 |
general form is |
| 1601 |
<dl><dd><table border="0"><tr><td><p style="font-size:12px;padding-left:.5em;padding-right:.5em;"><I>treeName</I> <B>notify</B> <I>operation</I> ?<I>arg</I>?...</table></dl> |
| 1602 |
Both <I>operation</I> and its arguments determine the exact behavior of |
| 1603 |
the command. The operations available for events are listed below. |
| 1604 |
<P> |
| 1605 |
<DL class="notify operations"> |
| 1606 |
<DT><A NAME="M269"><I>treeName</I> <B>notify create</B> ?<I>switches</I>? <I>command</I> ?<I>args</I>?...</A><DD> |
| 1607 |
Creates a notifier for the tree. A notify identifier in the form |
| 1608 |
"<B>notify0</B>", "<B>notify1</B>", etc. is returned. |
| 1609 |
<P> |
| 1610 |
<I>Command</I> and <I>args</I> are saved and invoked whenever the tree |
| 1611 |
structure is changed (according to <I>switches</I>). Two arguments are |
| 1612 |
appended to <I>command</I> and <I>args</I> before it's invoked: the id |
| 1613 |
of the node and a string representing the type of event that occured. |
| 1614 |
If an error is returned by <I>command</I>, and not using <I>-whenidle</I> |
| 1615 |
the invoking operation usually returns an error. |
| 1616 |
One of more switches can be set to indicate the events that are of |
| 1617 |
interest. The valid switches are as follows: |
| 1618 |
<P> |
| 1619 |
<DL class="notify operations"> |
| 1620 |
<DT><A NAME="M270"><B>-create</B></A><DD> |
| 1621 |
Invoke <I>command</I> whenever a new node is added. |
| 1622 |
This is called after the creation. Returning an error will |
| 1623 |
delete the node. |
| 1624 |
<P><DT><A NAME="M271"><B>-delete</B></A><DD> |
| 1625 |
Invoke <I>command</I> whenever a node has been deleted. |
| 1626 |
This is called before the delete starts to allow aborting it with an error. |
| 1627 |
Deletes resulting from failed inserts are ignored. |
| 1628 |
<P><DT><A NAME="M272"><B>-get</B></A><DD> |
| 1629 |
Invoke <I>command</I> whenever a node with no keys is accessed (via <B>get</B> |
| 1630 |
or <B>with</B>). |
| 1631 |
If a node has at least one key, this will not trigger. |
| 1632 |
The invocation occurs before the read, meaning it can |
| 1633 |
be used to implement demand loading of data keys into empty nodes |
| 1634 |
(eg. loading database row data on read). |
| 1635 |
<P><DT><A NAME="M273"><B>-insert</B></A><DD> |
| 1636 |
Invoke <I>command</I> when an <B>insert</B> completes. |
| 1637 |
This differs from <B>-create</B> in that the call occurs |
| 1638 |
after the label, tags and data are added (but before |
| 1639 |
<B>-fixed</B> gets set). |
| 1640 |
This trace applies to the subcommands <B>create</B>, <B>copy</B>, |
| 1641 |
<B>restore</B>, <B>sqlload</B>, and |
| 1642 |
<B>insert</B> (both tree and treeview). |
| 1643 |
It is useful for verifying key-data, tags and labels. |
| 1644 |
Returning an error will delete the node and cause the |
| 1645 |
originating command to generate an error. |
| 1646 |
<P><DT><A NAME="M274"><B>-move</B></A><DD> |
| 1647 |
Invoke <I>command</I> at the start of a node move. |
| 1648 |
<P><DT><A NAME="M275"><B>-movepost</B></A><DD> |
| 1649 |
Invoke <I>command</I> after a node has been moved. |
| 1650 |
<P><DT><A NAME="M276"><B>-sort</B></A><DD> |
| 1651 |
Invoke <I>command</I> whenever the tree has been sorted and reordered. |
| 1652 |
<P><DT><A NAME="M277"><B>-relabel</B></A><DD> |
| 1653 |
Invoke <I>command</I> at the start of a node relabel. |
| 1654 |
<P><DT><A NAME="M278"><B>-relabelpost</B></A><DD> |
| 1655 |
Invoke <I>command</I> after a node has been relabeled. |
| 1656 |
<P><DT><A NAME="M279"><B>-allevents</B></A><DD> |
| 1657 |
Invoke <I>command</I> whenever any of the above events occur. |
| 1658 |
<P><DT><A NAME="M280"><B>-whenidle</B></A><DD> |
| 1659 |
When an event occurs don't invoke <I>command</I> immediately, but |
| 1660 |
queue it to be run the next time the event loop is entered and there |
| 1661 |
are no events to process. If subsequent events occur before |
| 1662 |
the event loop is entered, <I>command</I> will still be |
| 1663 |
invoked only once. |
| 1664 |
<P></DL> |
| 1665 |
<P><DT><A NAME="M281"><I>treeName</I> <B>notify delete</B> <I>notifyId</I></A><DD> |
| 1666 |
Deletes one or more notifiers from the tree. <I>NotifyId</I> is the |
| 1667 |
notifier identifier returned by the <B>notify create</B> operation. |
| 1668 |
<P><DT><A NAME="M282"><I>treeName</I> <B>notify info</B> <I>notifyId</I></A><DD> |
| 1669 |
Returns information about the notify event <I>notifyId</I>. <I>NotifyId</I> |
| 1670 |
is a notify identifier previously returned by the <B>notify create</B> operation. |
| 1671 |
It's the same information specified for the <B>notify create</B> operation. |
| 1672 |
It consists of the notify id, a sublist of event flags (it's in the same |
| 1673 |
form as <I>flags</I>) and, the command prefix. |
| 1674 |
<P><DT><A NAME="M283"><I>treeName</I> <B>notify names</B></A><DD> |
| 1675 |
Returns a list of identifers for all the current notifiers. |
| 1676 |
|
| 1677 |
<P></DL> |
| 1678 |
<H3><A NAME="M284">TABLE EXAMPLE</A></H3> |
| 1679 |
The following is a simple example. |
| 1680 |
<P> |
| 1681 |
<PRE>variable Users { |
| 1682 |
tom { Name "Tom Brown" Sex M Age 19 Class {4 5} Rate {A 1 B 2}} |
| 1683 |
mary { Name "Mary Brown" Sex F Age 16 Class {5} Rate {A 2}} |
| 1684 |
sam { Name "Sam Spade" Sex M Age 19 Class {3 4} Rate {B 3}} |
| 1685 |
} |
| 1686 |
set t [tree create] |
| 1687 |
foreach {i d} $Users { |
| 1688 |
# Use name in -tags so we don't have to do "0->mary" etc. |
| 1689 |
$t insert 0 -tags $i -data $d -label $i |
| 1690 |
} |
| 1691 |
|
| 1692 |
$t update tom Sex F Name "Tomi Brown" |
| 1693 |
$t append sam Name " Jr" |
| 1694 |
$t lappend sam Class 5 |
| 1695 |
$t incr mary Age |
| 1696 |
$t update tom Rate(A) 2 |
| 1697 |
$t incr 0->mary Age |
| 1698 |
|
| 1699 |
# Set a trace. |
| 1700 |
proc ::Aupd {t id key op} { tclLog "AA: $t $id $key $op" } |
| 1701 |
$t trace create all Age w ::Aupd |
| 1702 |
$t incr mary Age |
| 1703 |
|
| 1704 |
# Display it. |
| 1705 |
pack [treeview .t -tree $t] -fill both -expand y |
| 1706 |
eval .t column insert end [$t keys all]</PRE> |
| 1707 |
<H3><A NAME="M285">TREE EXAMPLE</A></H3> |
| 1708 |
The following is a nested tree example with updates. |
| 1709 |
<P> |
| 1710 |
<PRE>variable Info { |
| 1711 |
system { |
| 1712 |
sol { OS Linux Version 3.4 } |
| 1713 |
bing { OS Win Version 7 } |
| 1714 |
gui { OS Mac Version 8 } |
| 1715 |
} |
| 1716 |
network { |
| 1717 |
intra { Address 192.168.1 Netmask 255.255.255.0 } |
| 1718 |
dmz { Address 192.168.10 Netmask 255.255.255.0 } |
| 1719 |
wan { Address 0.0.0.0 Netmask 0.0.0.0 Class {A 1 B 4}} |
| 1720 |
} |
| 1721 |
admins { |
| 1722 |
sully { Name "Sully Van Damme" Level 3 } |
| 1723 |
maverick { Name "Maverick Gump" Level 1 } |
| 1724 |
} |
| 1725 |
} |
| 1726 |
|
| 1727 |
set s [tree create] |
| 1728 |
foreach {n vals} $Info { |
| 1729 |
set ind [$s insert 0 -label $n] |
| 1730 |
foreach {i d} $vals { |
| 1731 |
$s insert $ind -label $i -data $d |
| 1732 |
} |
| 1733 |
} |
| 1734 |
|
| 1735 |
set old [$s get 0->system->bing] |
| 1736 |
$s update 0->system->bing OS Linux Version 3.4 |
| 1737 |
$s update 0->network->dmz Address 192.168.11 |
| 1738 |
$s update 0->network->wan Class(A) 2 |
| 1739 |
eval $s set 0->system->bing $old |
| 1740 |
$s insert 0->admins -label linus -data { Name "Linus Torvalds" Level 9 } |
| 1741 |
|
| 1742 |
|
| 1743 |
pack [treeview .s -tree $s -width 600] -fill both -expand y |
| 1744 |
eval .s column insert end [$s keys all]</PRE> |
| 1745 |
<H3><A NAME="M286">SQLLOAD EXAMPLE</A></H3> |
| 1746 |
Here is an example using <B>sqlload</B> on table <I>cust</I> from a |
| 1747 |
database file, and displaying it in a treeview: |
| 1748 |
<PRE>set t [tree create] |
| 1749 |
$t sqlload mydb.dat "select rowid,* from cust" |
| 1750 |
pack [treeview .t -tree $t -width 500] -fill both -expand y |
| 1751 |
eval .t column insert end [lsort [$t keys all]]</PRE> |
| 1752 |
Although there is no corresponding <B>sqldump</B> command, |
| 1753 |
scripting it is easy. Following |
| 1754 |
is one approach. |
| 1755 |
<PRE>proc sqldump {t db table {ids {}}} { |
| 1756 |
# Dump nodes from tree t into table in open sqlite database db. |
| 1757 |
if {$ids == {}} { set ids [$t children root] } |
| 1758 |
set keys [$t keys $ids] |
| 1759 |
catch { $db eval "CREATE TABLE $table ( [join $keys ,] )" } |
| 1760 |
$t with s $ids { |
| 1761 |
set nams {} |
| 1762 |
set vals {} |
| 1763 |
foreach nam $s(*) { |
| 1764 |
lappend vals \$s($nam) |
| 1765 |
lappend nams $nam |
| 1766 |
} |
| 1767 |
set vals [join $vals ,] |
| 1768 |
set nams [join $nams ,] |
| 1769 |
set q [format {INSERT INTO %s (%s) VALUES (%s)} $table $nams $vals] |
| 1770 |
$db eval $q |
| 1771 |
} |
| 1772 |
} |
| 1773 |
sqlite3 [set db dbhandle] mydb.dat |
| 1774 |
sqldump $t $db cust2</PRE> |
| 1775 |
<H3><A NAME="M287">TREE KEY STRING STORAGE</A></H3> |
| 1776 |
Key name strings |
| 1777 |
are stored by default in a global hash table. |
| 1778 |
However, sometimes this can be undesirable (eg. with threading), |
| 1779 |
and so the behavior may be changed (at tree create time only). |
| 1780 |
To enable per-interp storage of keys, set |
| 1781 |
<B>blt::treeKeysLocal</B> to 1 before tree creation. |
| 1782 |
To enable per-tree storage of keys, set |
| 1783 |
<B>blt::treeKeysLocal</B> to 2 before tree creation. |
| 1784 |
The above is unavailable in safe interps. |
| 1785 |
<H3><A NAME="M288">C LANGUAGE API</A></H3> |
| 1786 |
Blt_TreeApply, |
| 1787 |
Blt_TreeApplyBFS, |
| 1788 |
Blt_TreeApplyDFS, |
| 1789 |
Blt_TreeChangeRoot, |
| 1790 |
Blt_TreeCreate, |
| 1791 |
Blt_TreeCreateEventHandler, |
| 1792 |
Blt_TreeCreateNode, |
| 1793 |
Blt_TreeCreateTrace, |
| 1794 |
Blt_TreeDeleteEventHandler, |
| 1795 |
Blt_TreeDeleteNode, |
| 1796 |
Blt_TreeDeleteTrace, |
| 1797 |
Blt_TreeExists, |
| 1798 |
Blt_TreeFindChild, |
| 1799 |
Blt_TreeFirstChild, |
| 1800 |
Blt_TreeFirstKey, |
| 1801 |
Blt_TreeGetNode, |
| 1802 |
Blt_TreeGetToken, |
| 1803 |
Blt_TreeGetValue, |
| 1804 |
Blt_TreeIsAncestor, |
| 1805 |
Blt_TreeIsBefore, |
| 1806 |
Blt_TreeIsLeaf, |
| 1807 |
Blt_TreeLastChild, |
| 1808 |
Blt_TreeMoveNode, |
| 1809 |
Blt_TreeName, |
| 1810 |
Blt_TreeNextKey, |
| 1811 |
Blt_TreeNextNode, |
| 1812 |
Blt_TreeNextSibling, |
| 1813 |
Blt_TreeNodeDegree, |
| 1814 |
Blt_TreeNodeDepth, |
| 1815 |
Blt_TreeNodeId, |
| 1816 |
Blt_TreeNodeLabel, |
| 1817 |
Blt_TreeNodeParent, |
| 1818 |
Blt_TreePrevNode, |
| 1819 |
Blt_TreePrevSibling, |
| 1820 |
Blt_TreeRelabelNode, |
| 1821 |
Blt_TreeReleaseToken, |
| 1822 |
Blt_TreeRootNode, |
| 1823 |
Blt_TreeSetValue, |
| 1824 |
Blt_TreeSize, |
| 1825 |
Blt_TreeSortNode, and |
| 1826 |
Blt_TreeUnsetValue. |
| 1827 |
<H3><A NAME="M289">KEYWORDS</A></H3> |
| 1828 |
<A href="../Keywords/T.htm#tree">tree</A>, <A href="../Keywords/T.htm#treeview">treeview</A>, <A href="../Keywords/W.htm#widget">widget</A> |
| 1829 |
<div class="copy">Copyright © 1995-1997 Roger E. Critchlow Jr. |
| 1830 |
</div> |
| 1831 |
</BODY></HTML> |