<?xml version="1.0" encoding="windows-1252"?>
<node id="1004300" title="xs modifying passed value" created="2012-11-17 06:03:36" updated="2012-11-17 06:03:36">
<type id="115">
perlquestion</type>
<author id="988782">
Festus Hagen</author>
<data>
<field name="doctext">
Hey y'all,

&lt;p&gt;Trying to get the hang of this xs stuff and at a hump I can't seem to get over ...&lt;/P&gt;

&lt;p&gt;Modifying a passed parameter.&lt;br&gt;
The goal is to return the Int value and modify the passed arg to true or false (pass or fail on the conversion)&lt;/p&gt;

&lt;p&gt;MyLib is a stupid simple string class, strToInt() works correctly, both in the return value as well as modifying the passfail value.&lt;br&gt;
However, It does not show the changes in Perl.&lt;/p&gt;

&lt;p&gt;The xs code. (with some printf's)
&lt;code&gt;
int 
MyLib::strToInt(passfail)
	bool passfail;
CODE:
	if(passfail) {
		printf("It's true in xs. %i\n", passfail);
	} else {
	  printf("It's false in xs. %i\n", passfail);
	}
	RETVAL = THIS-&gt;strToInt(&amp;passfail);
	if(passfail) {
		printf("It's true out xs. %i\n", passfail);
	} else {
		printf("It's false out xs. %i\n", passfail);
	}
OUTPUT:
	RETVAL
	passfail
&lt;/code&gt;
&lt;/p&gt;

&lt;p&gt;The Perl calling code.
&lt;code&gt;
my $passfail = 0;
my $tmp = MyLib-&gt;new("12");
my $t = $tmp-&gt;strToInt(\$passfail);
print "It's $t\n" if $passfail eq 1;
&lt;/code&gt;
&lt;/p&gt;

&lt;p&gt;The above code produces the following output:
&lt;code&gt;
It's false in xs. 0
It's true out xs. 1
&lt;/code&gt;So the xs and C code works&lt;/p&gt;

&lt;p&gt;What the blazes am I doing wrong!&lt;br&gt;
Perlxstut makes it look simple ...&lt;/p&gt;

&lt;p&gt;Thanks&lt;/p&gt;

&lt;p&gt;-Enjoy&lt;br&gt;fh &lt;b&gt;&lt;font color="#FF0000"&gt;:&lt;/font&gt;&lt;/b&gt; )_~&lt;/p&gt;</field>
</data>
</node>
