File: cr.tcl

package info (click to toggle)
critcl 3.3.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,680 kB
  • sloc: ansic: 41,058; tcl: 12,090; sh: 7,230; pascal: 3,456; asm: 3,058; ada: 1,681; cpp: 1,001; cs: 879; makefile: 333; perl: 104; xml: 95; f90: 10
file content (54 lines) | stat: -rw-r--r-- 1,375 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
#!/usr/bin/env tclsh
# -*- tcl -*-
# Run the example via mode "compile & run".
# Note: generic code, same in all examples.

cd [file dirname [file normalize [info script]]]

package require critcl 3.2

puts v=[set v [package present critcl]]
puts [package ifneeded critcl $v]

package require critcl::class

puts v=[set vc [package present critcl::class]]
puts [package ifneeded critcl::class $vc]

# Show the config
puts ""
puts "target-config:   [critcl::targetconfig]"
puts "target-platform: [critcl::targetplatform]"
puts "target-actual:   [critcl::actualtarget]"
puts "build-platform:  [critcl::buildplatform]"
puts "cache:           [critcl::cache]"
puts ""

# Pull the package, ignoring build and examples ...
foreach f [glob *.tcl] {
    if {[string match build* $f]} continue
    if {[string match cr* $f]} continue
    if {[string match example* $f]} continue

    puts "Reading $f ..."
    source $f
}

proc ex {args} {
    set code [catch {uplevel 1 $args} result]
    set code [string map {0 ok 1 error 2 break 3 continue} $code]
    set max  [expr {80 - [string length $args] - [string length "Example: "]}]
    puts "Example: $args [string repeat _ $max]"
    puts "Code:    (($code))"
    puts "Result:  (($result))"
    puts ""
    return
}

# ... and run the examples.
foreach f [glob -nocomplain example*] {
    puts "Running $f ..."
    source $f
}

exit