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

« back to all changes in this revision

Viewing changes to Examples/lua/simple/runme.lua

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-12-05 01:16:04 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051205011604-ygx904it6413k3go
Tags: 1.3.27-1ubuntu1
Resynchronise with Debian again, for the new subversion packages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
---- importing ----
 
2
if string.sub(_VERSION,1,7)=='Lua 5.0' then
 
3
        -- lua5.0 doesnt have a nice way to do this
 
4
        lib=loadlib('example.dll','Example_Init') or loadlib('example.so','Example_Init')
 
5
        assert(lib)()
 
6
else
 
7
        -- lua 5.1 does
 
8
        require('example')
 
9
end
 
10
 
 
11
-- Call our gcd() function
 
12
x = 42
 
13
y = 105
 
14
g = example.gcd(x,y)
 
15
print("The gcd of",x,"and",y,"is",g)
 
16
 
 
17
-- Manipulate the Foo global variable
 
18
 
 
19
-- Output its current value
 
20
print("Foo = ", example.Foo)
 
21
 
 
22
-- Change its value
 
23
example.Foo = 3.1415926
 
24
 
 
25
-- See if the change took effect
 
26
print("Foo = ", example.Foo)
 
27
 
 
28
 
 
29
 
 
30
 
 
31
 
 
32
 
 
33
 
 
34
 
 
35