×

Good News Everybody!

The new search engine is LIVE!

Please report any problems to david (at) midrange.com.




You're copying FIELDXYZ which is defined as VARLEN in your DDS to PARMIMAGE
which is a fixed-length data structure in your RPG IV program.

The EVAL will copy the data starting in position 2 of FIELDXYZ into position
1 of PARMIMAGE. Then you set the PARMLEN field to value in PARMDATA start in
position 2.

What you should be doing is this:

Eval ParmData = FIELDXYZ
Eval ParmLen = %len(FieldXYZ)

-Bob

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx]
On Behalf Of Vicky.Wilkinson@xxxxxxxxxxxx
Sent: Monday, February 21, 2005 4:37 AM
To: rpg400-l@xxxxxxxxxxxx
Subject: Problems Passing Pointers as Parameters

Problems Passing Pointers as Parameters;

Calling Service Program

I am retrieving the length of a parameter from a file. 

Based on the length oh the parameter I am allocating memory and setting my 
pointer to the address.

I am also populating a data structure with data from a field in a file 
which is varying length. 

In order to copy the data from the varying length field into my allocated 
memory I have defined a varying field which is pointer based (address 
being the memory storage).

I am them calling a program passing the pointer as a parameter.

Service Pgm Code :

H NOMAIN 
 * 
D PARMPGM       PR 
D  ProgramId                    10A   Value 
 * 
P PARMPGM       B                   Export 
 * 
D PARMPGM       PI 
D  ProgramId                    10A   Value 
 * 
 * File; 
Fxyz       IF   E             Disk 
 * 
D BuffPtr            S               * 
D ProgId           S             10A 
D ParmVary     S           4096A   Varying 
D                                                       Based(BuffPtr)    
 * 
D ParmImage       DS          4098 
D  ParmLen                            5U 0  Overlay(ParmImage:1) 
D  ParmData                   4096         Overlay(ParmImage:3) 
 * 
 * Allocate memory and set pointer; 
C                   Eval      PLen = 512 
C                   Eval      BuffPtr = %Alloc(PLen) 
 * 
 * Populate DS and copy to allocated memory; 
C                   Eval      ParmImage = fieldxyz 
C                   Eval      ParmVary = %Subst(ParmData:1:PLen) 
 * Call program; 
C                   Call      ProgId 
C                   Parm                    Parm1Ptr 
 * 
C                   Return 
 * 
P  PARMPGM      E 


Called Program

In the called program I have an external file which I delare as a data 
structure which is pointer based. 
.
*Define entry list pointer
D Parm1Ptr        S               * 
 * 
 * Program passing parameters through datastructure; 
D Parm1         E DS                  Extname(PARMLS) 
D                                                   Based(Ptr1)  

My *Entry list receives my passed pointer.

C     *Entry        Plist 
C                   Parm                    Parm1Ptr 

I then set the pointer based over my data structure to the value of the 
passed in pointer in order to view the details of my parameter list.
C                   Eval      Ptr1 = Parm1Ptr 


My problem is that when I view my parameter list I have 2 invalid 
characters which I believe has something to do with the varying field used 
to copy data into memory.  I have tried moving the offset of the pointer 
by 2 to strip out these characters but end up with data being overlayed on 
my data structure being out by 2.


> PARM1 :C 10 = 
           ....5...10
      1   '           '
 
-- 
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.





As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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

This mailing list archive is Copyright 1997-2026 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.