PageRenderTime 8ms CodeModel.GetById 1ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/tcl/variables/runme.tcl

#
TCL | 76 lines | 59 code | 14 blank | 3 comment | 0 complexity | f39854b5a1bd24c62769480857ee6357 MD5 | raw file
 1# file: runme.tcl
 2
 3catch { load ./example[info sharedlibextension] example}
 4
 5# Try to set the values of some global variables
 6
 7set ivar    42
 8set svar   -31000
 9set lvar    65537
10set uivar   123456
11set usvar   61000
12set ulvar   654321
13set scvar   -13
14set ucvar   251
15set cvar    "S"
16set fvar    3.14159
17set dvar    2.1828
18set strvar  "Hello World"
19set iptrvar [new_int 37]
20set ptptr [new_Point 37 42]
21set name    "Bill"
22
23# Now print out the values of the variables
24
25puts "Variables (values printed from Tcl)"
26
27puts "ivar      = $ivar"
28puts "svar      = $svar"
29puts "lvar      = $lvar"
30puts "uivar     = $uivar"
31puts "usvar     = $usvar"
32puts "ulvar     = $ulvar"
33puts "scvar     = $scvar"
34puts "ucvar     = $ucvar"
35puts "fvar      = $fvar"
36puts "dvar      = $dvar"
37puts "cvar      = $cvar"
38puts "strvar    = $strvar"
39puts "cstrvar   = $cstrvar"
40puts "iptrvar   = $iptrvar"
41puts "name      = $name"
42puts "ptptr     = $ptptr [Point_print $ptptr]"
43puts "pt        = $pt [Point_print $pt]"
44
45puts "\nVariables (values printed from C)"
46
47print_vars
48
49puts "\nNow I'm going to try and modify some read only variables";
50
51puts "     Tring to set 'path'";
52if { [catch {
53    set path "Whoa!"
54    puts "Hey, what's going on?!?! This shouldn't work"
55}]} {
56    puts "Good."
57}
58
59puts "     Trying to set 'status'";
60if { [catch {
61    set status 0
62    puts "Hey, what's going on?!?! This shouldn't work"
63}]} {
64    puts "Good."
65}
66
67puts "\nI'm going to try and update a structure variable.\n"
68
69set pt $ptptr
70
71puts "The new value is"
72pt_print
73puts "You should see the value [Point_print $ptptr]"
74
75
76