1# Simple demo, can be used to verify proper Mk4tcl installation 2 3load ../builds/Mk4tcl[info sharedlibextension] Mk4tcl 4puts "[info script] - Mk4tcl [package require Mk4tcl] - $tcl_platform(os)" 5 6# On first run, output should consist of 5 lines: 7# John Lennon 44 8# Flash Gordon 42 9# Flash Gordon 42 10# John Lennon 44 11# John Lennon 44 12# Each following run will generate 5 more lines of output 13 14 # create a file called "demo.db" 15mk::file open db demo.db -nocommit 16 # define a view in it called "people", containing three fields 17mk::view layout db.people {first last shoesize:I} 18set vw [mk::view open db.people] 19 20 # let's append two rows to the end of the view 21$vw insert end first John last Lennon shoesize 44 22$vw insert end first Flash last Gordon shoesize 42 23 24 # commit the structure and data to file 25mk::file commit db 26 27 # a simple loop to print out all rows 28for {set r 0} {$r < [$vw size]} {incr r} { 29 puts [$vw get $r first last shoesize] 30} 31 32 # another way to loop, in sorted order 33foreach r [$vw select -sort last] { 34 puts [$vw get $r first last shoesize] 35} 36 37 # this loop iterates over a selection 38foreach r [$vw select first John] { 39 puts [$vw get $r first last shoesize] 40} 41