PageRenderTime 25ms CodeModel.GetById 14ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/tcl/class/runme.tcl

#
TCL | 50 lines | 27 code | 14 blank | 9 comment | 0 complexity | df8f7294d88f3c660efe9c27b1259dab MD5 | raw file
 1# file: runme.tcl
 2
 3# This file illustrates the high level C++ interface.
 4# In this case C++ classes work kind of like Tk widgets
 5
 6catch { load ./example[info sharedlibextension] example}
 7
 8# ----- Object creation -----
 9
10puts "Creating some objects:"
11Circle c 10
12puts "    Created circle [c cget -this]"
13Square s 10
14puts "    Created square [s cget -this]"
15
16# ----- Access a static member -----
17
18puts "\nA total of $Shape_nshapes shapes were created"
19
20# ----- Member data access -----
21
22# Set the location of the object
23
24c configure -x 20 -y 30
25s configure -x -10 -y 5
26
27puts "\nHere is their current position:"
28puts "    Circle = ([c cget -x], [c cget -y])"
29puts "    Square = ([s cget -x], [s cget -y])"
30
31# ----- Call some methods -----
32
33puts "\nHere are some properties of the shapes:"
34foreach o "c s" {
35      puts "    [$o cget -this]"
36      puts "        area      = [$o area]"
37      puts "        perimeter = [$o perimeter]"
38}
39
40# ----- Delete everything -----
41
42puts "\nGuess I'll clean up now"
43
44# Note: this invokes the virtual destructor
45rename c ""
46rename s ""
47
48puts "$Shape_nshapes shapes remain"
49puts "Goodbye"
50