| 1 |
#!/usr/bin/env tclsh |
| 2 |
# -*- tcl -*- |
| 3 |
# Run the example via mode "compile & run". |
| 4 |
# Note: generic code, same in all examples. |
| 5 |
|
| 6 |
cd [file dirname [file normalize [info script]]] |
| 7 |
source ../../lib/critcl/critcl.tcl |
| 8 |
|
| 9 |
# Show the config |
| 10 |
puts "" |
| 11 |
puts "target-config: [critcl::targetconfig]" |
| 12 |
puts "target-platform: [critcl::targetplatform]" |
| 13 |
puts "target-actual: [critcl::actualtarget]" |
| 14 |
puts "build-platform: [critcl::buildplatform]" |
| 15 |
puts "cache: [critcl::cache]" |
| 16 |
puts "" |
| 17 |
|
| 18 |
# Pull the package, ignoring build and examples ... |
| 19 |
foreach f [glob *.tcl] { |
| 20 |
if {[string match build* $f]} continue |
| 21 |
if {[string match cr* $f]} continue |
| 22 |
if {[string match example* $f]} continue |
| 23 |
|
| 24 |
puts "Reading $f ..." |
| 25 |
source $f |
| 26 |
} |
| 27 |
|
| 28 |
proc ex {args} { |
| 29 |
set code [catch {uplevel 1 $args} result] |
| 30 |
set code [string map {0 ok 1 error 2 break 3 continue} $code] |
| 31 |
set max [expr {80 - [string length $args] - [string length "Example: "]}] |
| 32 |
puts "Example: $args [string repeat _ $max]" |
| 33 |
puts "Code: (($code))" |
| 34 |
puts "Result: (($result))" |
| 35 |
puts "" |
| 36 |
return |
| 37 |
} |
| 38 |
|
| 39 |
# ... and run the examples. |
| 40 |
foreach f [glob -nocomplain example*] { |
| 41 |
puts "Running $f ..." |
| 42 |
source $f |
| 43 |
} |
| 44 |
|
| 45 |
exit |