× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



The first two bytes of a varying length string are the length of the 
varying length string.  Normally if you just evaluate the string like
eval FixedChar = VarLengthChar;
it doesn't matter.  But sticking that bad boy into a datastructure...

Rob Berendt
-- 
Group Dekko Services, LLC
Dept 01.073
PO Box 2000
Dock 108
6928N 400E
Kendallville, IN 46755
http://www.dekko.com





Vicky.Wilkinson@xxxxxxxxxxxx 
Sent by: rpg400-l-bounces@xxxxxxxxxxxx
02/21/2005 05:37 AM
Please respond to
RPG programming on the AS400 / iSeries <rpg400-l@xxxxxxxxxxxx>


To
rpg400-l@xxxxxxxxxxxx
cc

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-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.