I'm not a php developer, but one thing that struck me is that your code used both array() and Array() constructors. Are array constructors case sensitive in php? They are in JavaScript.

Nathan.




----- Original Message ----
From: Shannon ODonnell <sodonnell@xxxxxxxxxxxxxxxxxxxxxxxxx>
To: Web Enabling the AS400 / iSeries <web400@xxxxxxxxxxxx>
Sent: Friday, February 27, 2009 8:17:42 AM
Subject: [WEB400] PHP Syntax Question

Hi,



I posted this question on Zend's forum but got no response so hopefully one
of the PHP users on here can provide some insight to me on this.



I am having trouble understanding why I cannot print the contents of a
returned PHP array from an I5_Program_Call.

It could be because of the way the data structure array(s) are defined in my
RPGLE program and that I am not defining them correctly in my PHP script.



============================================================================
==================================================

Here's the PCML (it's pretty short)



<pcml version="4.0">

<!-- RPG program: ATESTX1 -->

<!-- created: 2009-02-27-08.55.11 -->

<!-- source: ALIB/QRPGLESRC(ATESTX1) -->

<!-- 13 -->

<struct name="OUT_ARRAY">

<data name="OUT_NAME1" type="char" length="30" usage="inherit" />

<data name="OUT_TICKET1" type="char" length="14" usage="inherit" />

</struct>

<program name="ATESTX1" path="/QSYS.LIB/ALIB.LIB/ATESTX1.PGM">

<data name="KSOCKCN" type="char" length="2" usage="inputoutput" />

<data name="KSOCKYR" type="char" length="2" usage="inputoutput" />

<data name="KSOCKTY" type="char" length="2" usage="inputoutput" />

<data name="KSOCKNO" type="char" length="7" usage="inputoutput" />

<data name="OUT_NAME" type="char" length="30" usage="inputoutput" />

<data name="OUT_TICKET" type="char" length="14" usage="inputoutput" />

<data name="OUT_ARRAY" type="struct" struct="OUT_ARRAY" count="5"
usage="inputoutput" />

</program>

</pcml>





============================================================================
==============

And this is the relevant portion of the PHP Script (also short)







$in_parameters = Array( "KSOCKCN"=>"20",

"KSOCKYR"=>"05",

"KSOCKTY"=>"TR",

"KSOCKNO"=>"000054");





$out_parameters = array(

"OUT_NAME"=>"OUT_NAME",

"OUT_TICKET"=>"OUT_TICKET",

"OUT_ARRAY"=>Array("OUT_NAME1"=>"OUT_NAME1",

"OUT_TICKET1"=>"OUT_TICKET1"));





i5_program_call($hdlPgm, $in_parameters, $out_parameters);



echo "Out_Name is: <font color='red'><h2>".$OUT_NAME."</h2></font> and that
was the value of the Out_Name field<BR><BR>";



echo "Out_Ticket is: <font color='red'><h2>".$OUT_TICKET."</h2></font> and
that was the value of the Out_Ticket field<BR><BR>";



echo "Out_Name1 is: <font
color='blue'><h2>".$out_parameters["OUT_ARRAY"]["OUT_NAME1"][1]."</h2></font
and that was the value of the first array element<br><br>";



============================================================================
============================================================================
=====================================================


When I execute the PRINT statements at the end of the script, the values in
the fields OUT_NAME and OUT_TICKET print the contents just fine that were
returned from the RPG program.




But the values in the data structure array, OUT_ARRAY, and the fields
OUT_NAME1 and OUT_TICKET1 only print the values "OUT_NAME1" and
"OUT_TICKET1" which is the names of the local variables that I thought would
contain the returned data. Or, if I try to print just a single element, I
get whatever character is at that position in that variable name such as
print $out_parameters["OUT_ARRAY"]["OUT_NAME1"][1] would print the letter
"U".



So I am not understanding something here about how to define/refer to the
elements in an RPG data structure array in PHP.

I would appreciate any suggsetions on how to correclty define and print my
data structure arrays from the returned program call.

Thanks!



Shannon O'Donnell




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.