Bug in AddParameterUInt32

General discussion on Zend Server for IBM System i

Bug in AddParameterUInt32

Postby iplsbm on Wed Aug 29, 2012 2:41 pm

Hi all,

I think I found a bug in ToolkitService.php, function AddParameterUInt32 (XMLToolkit_12-07_Update).

I was trying to work with array of Char:
Code: Select all
$myChararray = $TSObj->AddParameterChar('both', 4,'mychar','mychar','ABCDEFGH','',4);

and UInt32:
Code: Select all
$myUInt32array = $TSObj->AddParameterUInt32('both', 'myUInt32','myUInt32', 4294967295,4);


myChararray is OK and my C program is able to retrieve the array passed.
myUInt32array is incorrect as only the 1st dimension ($myChararray[0]) was passed to my C program.

I made an other test with an array of Int32 and it works fine.

So I had a look at AddParameterInt32 and AddParameterUInt32 and I found a difference here:

static function AddParameterUInt32( $io, $comment, $varName = '', $value ,$dimension =0) {
return ( new UInt32Param ($io, $comment, $varName, $value, 'off', $dimension)) ;
}

The 5th param should be the dimension and not 'off'...

I simply removed it an now myUInt32array is successfully passed to my C program.

Here is my conf:

    V7R1
    Zend Server for IBM i (PHP 5.3) 5.6.0 New Installation
    Zend Server for IBM i 5.6.0 Hotfix 2
    Zend Server for IBM i 5.6.0 Hotfix 3
    XML Toolkit for IBM i 12.07

Please let me know if I misunderstood something...

Thanks.
iplsbm
 
Posts: 5
Joined: Wed Aug 29, 2012 1:44 pm

Re: Bug in AddParameterUInt32

Postby aseiden on Thu Aug 30, 2012 6:21 am

Thanks--yes, it's a copy/paste error. Your fix (removing the 'off' parameter) is correct.

You just illustrated a benefit of open source: users can detect and correct bugs.

I'll add this fix to the next version of the PHP portion of the toolkit (probably 1.3.2).

By the way, this is the first C program I've seen called by the toolkit. Glad it's working well!

--Alan Seiden
aseiden
 
Posts: 840
Joined: Thu Apr 09, 2009 5:45 pm

Re: Bug in AddParameterUInt32

Postby iplsbm on Thu Aug 30, 2012 1:02 pm

You're welcome.

It will be nice if you could add some functions/classes to work with Int16/Uint16 too...

I added AddParameterInt16/AddParameterUInt16 and Int16Param/UInt16Param in my toolkit and it's works fine with my C program.

Regards,

Bruno
iplsbm
 
Posts: 5
Joined: Wed Aug 29, 2012 1:44 pm

Re: Bug in AddParameterUInt32

Postby aseiden on Tue Sep 18, 2012 2:57 am

Bruno,

If your code for Int16/Uint16 works, I could add it to the toolkit. Then you won't have to maintain the code separately. Want to send it to me?

Alan
aseiden
 
Posts: 840
Joined: Thu Apr 09, 2009 5:45 pm

Re: Bug in AddParameterUInt32

Postby aseiden on Thu Oct 11, 2012 4:00 pm

Bruno,

The fix to UINT32 is included in PHP toolkit version 1.3.3.

Download page: http://www.youngiprofessionals.com/wiki/XMLSERVICE
Change log: http://174.79.32.155/wiki/index.php/XML ... WChangeLog

Thanks again for reporting the issue and solution.

Alan
aseiden
 
Posts: 840
Joined: Thu Apr 09, 2009 5:45 pm

Re: Bug in AddParameterUInt32

Postby iplsbm on Wed Nov 28, 2012 11:34 am

Hi Alan,

I'm really sorry to be so late answering your post (I just read it).
I will try your fix as soon as possible.

Here is my code for Int16/Uint16:

Code: Select all
In ToolkitService.php:

// Start change

//Signed short
function AddParameterInt16( $io,  $comment,  $varName = '', $value, $dimension = 0 ) {
    return(new Int16Param ($io, $comment, $varName, $value, $dimension));
}
// Unsigned short
function AddParameterUInt16( $io,  $comment,  $varName = '', $value, $dimension = 0 ) {
    return(new UInt16Param ($io, $comment, $varName, $value, $dimension));
}

// End   change


In ToolkitServiceParameter.php:

// Start change

// Signed short
class Int16Param extends ProgramParameter{
    function __construct($io,  $comment,  $varName = '', $value, $dimension=0, $by='', $isArray = false, $labelSetLen = null) {
      parent::__construct('5i0', $io, $comment, $varName, $value, 'off', $dimension, $by, $isArray, $labelSetLen, null  );
      return $this;
    }
}
// Unsigned short
class UInt16Param extends ProgramParameter{
    function __construct($io,  $comment,  $varName = '', $value, $dimension=0, $by='', $isArray = false, $labelSetLen = null) {
      parent::__construct('5u0', $io, $comment, $varName, $value, 'off', $dimension, $by, $isArray, $labelSetLen, null  );
      return $this;
    }
}
// End   change


Regards,

Bruno.
iplsbm
 
Posts: 5
Joined: Wed Aug 29, 2012 1:44 pm

Re: Bug in AddParameterUInt32

Postby aseiden on Wed Dec 05, 2012 6:36 am

Bruno, thanks, I will add these.

Alan
aseiden
 
Posts: 840
Joined: Thu Apr 09, 2009 5:45 pm


Return to Zend Server for IBM i

Who is online

Users browsing this forum: No registered users and 3 guests