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



A simpler way to do it is to let the compiler handle the pointer math for you. 
This works find as long as you will not have more than 65537 records for array 
of records or 32767 for multiple occurrence data structure. 

First way is to use a multiple occurrence data structure.  

d dsStructure...
d                           ds                      Qualified
d                                                   Occurs(32767)
d                                                   Based(ptrStructure)
d  YourField1...
d  Yourfield2...
 /free

  ptrStructure = USPC_GetPointerToUserSpace(...);

  // From this point on, just treat like any multiple occurrence data 
structure. 
  // When you occurs, system does pointer math. 
 For x = 1 to Top;
  %Occurs(dsStructure) = x;
   dsStructure.YourField1 = (Your Code);
   dsStructure.YourField2 = (Your code);
EndFor;
  
Other way is to use array of records. 

d myArray...
d                        ds                          Qualified
d                                                    Dim(65534)
d                                                    Based(ptrArray)
d   YourField1...
d   YourField2...
 /Free

  ptrArray = USPC_GetPointerToUserSpace(...);

  // Now you can just treat as array and compiler does pointer math. 

  For x =- 1 to Top;
    myArray(x).YourField1 = (Your code);
    myArray(x).YourField2 = (Your code);
  EndFor;

Either way is best. Easy to screw up pointer math. 


got a userspace (which is set to autoextend) and in my rpg program i am
retrieving a pointer to that userspace. through pointer arithmetic i am
filling the userspace with some values.

D usPtr           S               *
D usData          DS                  based(usPtr) qualified
D   header                            likeds(wws_main_us)

D usDataPtr       S               *
D vkst            S              5  0 based(usDataPtr)

dow (not %eof);
  usDataPtr = usPtr + %len(usData.header) +
 >>             (i * %size(vkst));
 >> vkst = someValue;
 >>  i += 1;
 >> read file;
enddo;



As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.