~ubuntu-branches/ubuntu/warty/swig1.3/warty

« back to all changes in this revision

Viewing changes to Examples/ruby/variables/runme.rb

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Landschoff
  • Date: 2002-03-29 01:56:07 UTC
  • Revision ID: james.westby@ubuntu.com-20020329015607-c0wt03xu8oy9ioj7
Tags: upstream-1.3.11
ImportĀ upstreamĀ versionĀ 1.3.11

Show diffs side-by-side

added added

removed removed

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