On 27-Feb-09, at 1:00 PM, web400-request@xxxxxxxxxxxx wrote:
I am having trouble understanding why I cannot print the contents of a
returned PHP array from an I5_Program_Call.
Shannon,
The example below works - it is not as complex a situation as yours (I
always work from simple - it suits my brain!) but you should be able
to adapt. I'm also going to copy my Zend contacts on this because
there are no examples of using an array that I can find and there are
things like countref that are available in the interface that I can
find nothing about at all.
Anyway - here's the PHP:
<?php
include("conn.php");
/* connection step */
$Hdlcon = i5_connect($connect,$user, $pass,
array(I5_OPTIONS_JOBNAME=>"I5JOB"));
$description = file_get_contents("/www/zendcore/htdocs/ARRAY.pcml")
or trigger_error("Error while opening PCML file", E_USER_ERROR);
// Prepare the program
($hdlPgm = i5_program_prepare_PCML($description))
or trigger_error("Error while parsing PCML: " . i5_errormsg(),
E_USER_ERROR);
// Define input values
$in_parameters = Array("IOARRAY"=>array("One","Two","Three","Four"));
// And output variables
$out_parameters = array("IOARRAY"=>"IOARRAY");
echo "<br>Here's the input parms: ";
var_dump($in_parameters);
// Make the call
i5_program_call($hdlPgm, $in_parameters, $out_parameters)
or trigger_error("Error while executing program: " . i5_errormsg(),
E_USER_ERROR);
echo "<br><br>And here's the resulting output: ";
var_dump($IOARRAY);
?>
And here's the RPG program. The Printer part was introduced because I
couldn't tell where the failures were occurring.
FQprint O F 132 Printer
D Array Pr ExtPgm('ARRAY/PARTNER400')
D IOArray 5a Dim(4)
D Array PI
D IOArray 5a Dim(4)
D x S 5i 0
/Free
except info;
For x = 1 to %Elem(IOArray);
IOArray(x) = %Char(x);
EndFor;
except info;
*InLR = *On;
/End-Free
OQprint E info 2
O IOArray(1) 12
O IOArray(2) 24
Hope this helps.
We could certainly do with a few more examples of this type of program
call.
Jon Paris
www.Partner400.com
www.SystemiDeveloper.com
As an Amazon Associate we earn from qualifying purchases.