Purpose: To provide an index to all pages on this Wiki containing tutorial material. ---- To see a list of all tutorial-related pages on this Wiki, click on the above title. To add a tutorial-related page to this category, add a link to this page to the tutorial page, e.g., [Category Tutorial]. [Category Category] UPLEVEL #nomobaloney@hotmail.com: Hi, Avia and sincere thanks to the CORE team, R.Suchenwirth(jeez) and like minds(D.Libes, D.Porter). This is just a brief description and example of how to use uplevel to obtain some "advanced" looking effects. My initial impulse was to create a "C struct" type DS. Like CL recommended-> The tcl way is better. ;) This whole thing is decidedly beta so if you have problems with it don't come running,or complaining. I code for fun, not profit. Note: If someone could give me some pointers on how to format uplevel commands this would look better I'm sure. Add.Note: Please let me know when and how this breaks. It's totally beta ,has no error checking,.etc..blah I mean besides that. proc DataObj {args} { set num [llength $args] foreach member $args { ; regsub -all "\[\(\)\]" $args "" args if {![regexp "(\[ailst\])\.(\[a-zA-Z\]+)\.(.*)" $member a c d e]} { error "Invalid struct member. Not identifiable." } ; puts "$a == all, $c == first , $d == second , $e == third." lappend namelist $member switch -exact -- $c { "l" { uplevel #0 " set [subst -novariable $d] \[eval $e\] " } "a" { uplevel #0 " set x 0 ; array set [subst -novariable $d] {} foreach n \[eval $e\] { set [subst -novariable $d](\[incr x\]) \$n } ; set x 0 " } "s" { uplevel #0 " set [subst -novariable $d] $e " } "i" { uplevel #0 " set [subst -novariable $d] $e " } "t" { uplevel #0 "eval {proc $d {{xlist \"$namelist\"}} { foreach nme \$xlist { set base \[split \$nme \".\"\] if {\"\[lindex \$base 0\]\" == \"a\"} { set arr \[lindex \$base 1\] ; uplevel #0 \"parray \$arr\" } elseif {\"\[lindex \$base 0\]\" == \"i\"} { set in \[lindex \$base 1\] ; uplevel #0 \"puts \$\$in\" } elseif {\"\[lindex \$base 0\]\" == \"s\"} { set in \[lindex \$base 1\] ; uplevel #0 \"puts \$\$in\" } elseif {\"\[lindex \$base 0\]\" == \"l\"} { set lis \[lindex \$base 1\] ; uplevel #0 \"puts \$\$lis\" } } }}" } } } return } What this conniption does is use various areas of the tcl stack space to create some global "data structures" that can be called from a handler "t.?.?" in a format friendly to those people working with JS, or one of the OA languages. On the other hand it might not do what I think..this IS the intermediate area after all. Without a handler the structures are still created globally. Eventually I would like to have: 1) Traces on each variable to unset the remaining "members" on an unset of one or at least some more advanced error catching. 2) A global store of DataObj that is consulted periodically to create pseudo garbage collection. 3) Cleaner code(Once can dream , right?) 4) Strong typing(?via regexp?) for error control. Since it's not done a handler is not mandatory. The general format is: s = string i = int(numeric) a = array l = list (Yeah, I thought all this up by myself) So: > DataObj s.nme.thisstring a.arra.nums l.mylist.nums i.twenty.20 t.ref.NULL Results in: > ref (just call it by name) thisstring arra(1) = 20 arra(10) = 29 arra(100) = 119 arra(101) = 120 arra(102) = 121 arra(103) = 122 arra(104) = 123 arra(105) = 124 arra(106) = 125 arra(107) = 126 arra(108) = 127 arra(109) = 128 arra(11) = 30 arra(110) = 129 arra(111) = 130 arra(112) = 131 arra(113) = 132 arra(114) = 133 arra(115) = 134 arra(116) = 135 arra(117) = 136 arra(118) = 137 arra(119) = 138 arra(12) = 31 arra(120) = 139 arra(121) = 140 arra(122) = 141 arra(123) = 142 arra(124) = 143 arra(125) = 144 arra(126) = 145 arra(127) = 146 arra(128) = 147 arra(129) = 148 arra(13) = 32 arra(130) = 149 arra(131) = 150 arra(14) = 33 arra(15) = 34 arra(16) = 35 arra(17) = 36 arra(18) = 37 arra(19) = 38 arra(2) = 21 arra(20) = 39 arra(21) = 40 arra(22) = 41 arra(23) = 42 arra(24) = 43 arra(25) = 44 arra(26) = 45 arra(27) = 46 arra(28) = 47 arra(29) = 48 arra(3) = 22 arra(30) = 49 arra(31) = 50 arra(32) = 51 arra(33) = 52 arra(34) = 53 arra(35) = 54 arra(36) = 55 arra(37) = 56 arra(38) = 57 arra(39) = 58 arra(4) = 23 arra(40) = 59 arra(41) = 60 arra(42) = 61 arra(43) = 62 arra(44) = 63 arra(45) = 64 arra(46) = 65 arra(47) = 66 arra(48) = 67 arra(49) = 68 arra(5) = 24 arra(50) = 69 arra(51) = 70 arra(52) = 71 arra(53) = 72 arra(54) = 73 arra(55) = 74 arra(56) = 75 arra(57) = 76 arra(58) = 77 arra(59) = 78 arra(6) = 25 arra(60) = 79 arra(61) = 80 arra(62) = 81 arra(63) = 82 arra(64) = 83 arra(65) = 84 arra(66) = 85 arra(67) = 86 arra(68) = 87 arra(69) = 88 arra(7) = 26 arra(70) = 89 arra(71) = 90 arra(72) = 91 arra(73) = 92 arra(74) = 93 arra(75) = 94 arra(76) = 95 arra(77) = 96 arra(78) = 97 arra(79) = 98 arra(8) = 27 arra(80) = 99 arra(81) = 100 arra(82) = 101 arra(83) = 102 arra(84) = 103 arra(85) = 104 arra(86) = 105 arra(87) = 106 arra(88) = 107 arra(89) = 108 arra(9) = 28 arra(90) = 109 arra(91) = 110 arra(92) = 111 arra(93) = 112 arra(94) = 113 arra(95) = 114 arra(96) = 115 arra(97) = 116 arra(98) = 117 arra(99) = 118 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 20 So I hope this hasn't been a total waste of your time,even as a lesson in what NOT to do. Later.