New example
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@743 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
3621fe789f
commit
b8c6298c42
7 changed files with 285 additions and 0 deletions
65
Examples/perl5/variables/example.pl
Normal file
65
Examples/perl5/variables/example.pl
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
# file: example.pl
|
||||
|
||||
use example;
|
||||
|
||||
# Try to set the values of some global variables
|
||||
|
||||
$example::ivar = 42;
|
||||
$example::svar = -31000;
|
||||
$example::lvar = 65537;
|
||||
$example::uivar = 123456;
|
||||
$example::usvar = 61000;
|
||||
$example::ulvar = 654321;
|
||||
$example::scvar = -13;
|
||||
$example::ucvar = 251;
|
||||
$example::cvar = "S";
|
||||
$example::fvar = 3.14159;
|
||||
$example::dvar = 2.1828;
|
||||
$example::strvar = "Hello World";
|
||||
$example::cstrvar = "Goodbye";
|
||||
$example::iptrvar= example::new_int(37);
|
||||
$example::ptptr = example::new_Point(37,42);
|
||||
$example::name = "Bill";
|
||||
|
||||
# Now print out the values of the variables
|
||||
|
||||
print "Variables (values printed from Python)";
|
||||
|
||||
print "ivar = $example::ivar\n";
|
||||
print "svar = $example::svar\n";
|
||||
print "lvar = $example::lvar\n";
|
||||
print "uivar = $example::uivar\n";
|
||||
print "usvar = $example::usvar\n";
|
||||
print "ulvar = $example::ulvar\n";
|
||||
print "scvar = $example::scvar\n";
|
||||
print "ucvar = $example::ucvar\n";
|
||||
print "fvar = $example::fvar\n";
|
||||
print "dvar = $example::dvar\n";
|
||||
print "cvar = $example::cvar\n";
|
||||
print "strvar = $example::strvar\n";
|
||||
print "cstrvar = $example::cstrvar\n";
|
||||
print "iptrvar = $example::iptrvar\n";
|
||||
print "name = $example::name\n";
|
||||
print "ptptr = $example::ptptr", example::Point_print($example::ptptr), "\n";
|
||||
print "pt = $example::pt", example::Point_print($example::pt), "\n";
|
||||
|
||||
print "\nVariables (values printed from C)\n";
|
||||
|
||||
example::print_vars();
|
||||
|
||||
print "\nI'm going to try and update a structure variable.\n";
|
||||
|
||||
$example::pt = $example::ptptr;
|
||||
|
||||
print "The new value is ";
|
||||
example::pt_print();
|
||||
print "You should see the value", example::Point_print($example::ptptr), "\n";
|
||||
|
||||
|
||||
print "\nNow I'm going to try and modify some read only variables\n";
|
||||
|
||||
print " Tring to set 'path'\n";
|
||||
$example::path = "Whoa!";
|
||||
|
||||
print " Trying to set 'status'\n";
|
||||
$example::status = 0;
|
||||
Loading…
Add table
Add a link
Reference in a new issue