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

/trunk/Examples/tcl/pointer/runme.tcl

#
TCL | 47 lines | 24 code | 14 blank | 9 comment | 0 complexity | 43b0e4f751157b23b83e1e456912eff8 MD5 | raw file
 1# file: runme.tcl
 2
 3catch { load ./example[info sharedlibextension] example}
 4
 5# First create some objects using the pointer library.
 6puts "Testing the pointer library"
 7set a [new_intp]
 8set b [new_intp]
 9set c [new_intp]       ;# Memory for result
10
11intp_assign $a 37
12intp_assign $b 42
13
14puts "     a = $a"
15puts "     b = $b"
16puts "     c = $c"
17
18# Call the add() function with some pointers
19add $a $b $c
20
21# Now get the result
22set r [intp_value $c]
23puts "     37 + 42 = $r"
24
25# Clean up the pointers
26delete_intp $a
27delete_intp $b
28delete_intp $c
29
30# Now try the typemap library
31# This should be much easier. Now how it is no longer
32# necessary to manufacture pointers.
33
34puts "Trying the typemap library"
35set r [sub 37 42]
36puts "     37 - 42 = $r"
37
38# Now try the version with multiple return values
39
40puts "Testing multiple return values"
41set qr [divide 42 37]
42set q [lindex $qr 0]
43set r [lindex $qr 1]
44puts "     42/37 = $q remainder $r"
45
46
47