PageRenderTime 23ms CodeModel.GetById 1ms app.highlight 17ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/octave/pointer/runme.m

#
Objective C | 42 lines | 29 code | 13 blank | 0 comment | 0 complexity | d307b3f9559b270a4ba07e6abc5f6aca MD5 | raw file
 1# file: runme.m
 2
 3example;
 4
 5# First create some objects using the pointer library.
 6printf("Testing the pointer library\n");
 7a = example.new_intp();
 8b = example.new_intp();
 9c = example.new_intp();
10example.intp_assign(a,37);
11example.intp_assign(b,42);
12
13a,b,c
14
15# Call the add() function with some pointers
16example.add(a,b,c);
17
18# Now get the result
19r = example.intp_value(c);
20printf("     37 + 42 = %i\n",r);
21
22# Clean up the pointers
23example.delete_intp(a);
24example.delete_intp(b);
25example.delete_intp(c);
26
27# Now try the typemap library
28# This should be much easier. Now how it is no longer
29# necessary to manufacture pointers.
30
31printf("Trying the typemap library\n");
32r = example.sub(37,42);
33printf("     37 - 42 = %i\n",r);
34
35# Now try the version with multiple return values
36
37printf("Testing multiple return values\n");
38[q,r] = example.divide(42,37);
39printf("     42/37 = %d remainder %d\n",q,r);
40
41
42