# Reference
# Save a widget and link a textvariable
aitcs new rec
aitcs new gui
set fld preference
rec $fld Tcl
gui $fld [entry .e -textvariable [rec& $fld]]
[gui $fld] insert end /Tk
string length [rec preference]; # 6

# Get/Set
aitcs new things
things a 3
things b [expr {[things a] + 2}]
things c [expr {[things b] * [things a]}]
things c; # 15

# Exists
aitcs new colours
colours red #FF0000
colours? red; # 1
colours? green; # 0
colours? red color1; # 1
info exists color1; # 1
set color1; # #FF0000
colours? green color2; # 0
info exists color2; # 0

# Reference
aitcs new fruits
fruits= apple orange pear apricot 0
if {![fruits? peach]} {
   fruits= peach 0
}
array names [fruits&]; # {apple orange pear apricot peach}
fruits- p* a*
array names [fruits&]; # {orange}

# Get With Default
aitcs new things
things are good
things^ are ok; # good
things^ be ok; # ok
things^ willbe; # Empty string
things^ is nice here; # nice, and var here is set to nice

# Lappend
aitcs new store
store this one
store+ this two three four five
store this; # {one two three four five}

# Incr
aitcs new counters
counters cycles 0
counters+= cycles
counters+= cycles 2
counters+= cycles -1
counters cycles; # 2

# Make Exist/Exists
aitcs new cow
cow!
set cow(sound) moo
if {[cow? sound] && $cow(sound) eq "moo"} {
   puts "Standard English Cow"
}

# Command Reference/Variable Reference/Incr
aitcs new callback
callback count 0
after 1000 [list [callback&&]+= count]
vwait [callback& count]
callback count; # 1

# Struct Dereference/Random Name/Initial Values
aitcs new animals {} {} \
	dog [aitcs new {} {} {} says woof likes cat] \
	cat [aitcs new {} {} {} says meow likes dog]
animals home [list dog cat]
set res ""; foreach animal [animals home] {
	append res $animal " says " [animals. $animal says]
	append res " likes " [animals. $animal likes]
	append res " who says " [animals. [animals. $animal likes] says]\n
}
set res
# dog says woof likes cat who says meow
# cat says meow likes dog who says woof

# Struct Dereference
aitcs new outer
aitcs new inner
aitcs new innest
inner count 6
innest things [list]
innest+ things 1 2
outer member inner
inner item innest
outer. member+= count 2; # 8
outer. member. item+ things 3 4; # {1 2 3 4}
outer. member. item^ name; # Empty string

# Destroy
aitcs new tmp
tmp count 5
tmp+= count -1
tmp count; # 4
set fqarr [tmp&]
info exists $fqarr; # 1
tmp---
info exists $fqarr; # 0
tmp count; # <error>