|
Sorry for being so late on the reply, I posted it to the wrong list.
Nigel,
You really don't need the array. We use two procedures to support the
QUSLOBJ. One opens the list. The other returns a pointer to the entries.
We allow up to 20 lists to be open at a time. There are twenty element
arrays that store the space names, 1st element pointer, and current offset
and element length.
The procedure that opens the list receives an object and library name. It
also receives an optional format, type, space name, space library, and
space size. The optional values default to predetermined values if not
specified. After the space is created and loaded it initializes the
pointer to the first element using a sub-procedure that returns a pointer
to the space and adds the offsets.
The procedure that returns a pointer to an element first looks up the space
name in the space name array. It then multiplies the element number by the
element length and adds this to the 1st element pointer. This pointer is
returned to the application. It then increments the element number.
The application program that uses the object list procedures declares a
return area that is based on the pointer returned from the retrieve object
list entry pointer. I have included a piece of code to give you an idea
how this can work. The example uses the OBJL0400 format. The data is
never moved from the user space. You are only limited by the maximum size
of a user space.
/COPY QSYSINC/QRPGLESRC,QUSLOBJ
Define object fields
D**************************************
D* Return area for object description *
D**************************************
DObjLstPtr S * INZ(*NULL)
List element ptr.
D DS BASED(ObjLstPtr)
Retrieve objects.
D ObjNam LIKE(QUSOBJNU02)
Object Name Used
D ObjLib LIKE(QUSOLNU02)
Object Lib Name Used
D ObjTyp LIKE(QUSOBJTU02)
Object Type Used
D InfSts LIKE(QUSIS03)
Information Status
D ExtAtt LIKE(QUSEOA01)
Extended Obj Attr
D ObjTxt LIKE(QUSTD08)
Text Description
D UsrDefAtt LIKE(QUSUDA01)
User Defined Attr
D Reserved01 LIKE(QUSERVED24)
Reserved
D AuxStgP LIKE(QUSASP00)
Aux Storage Pool
D ObjOwnUsr LIKE(QUSOBJO00)
Object Owner
D ObjDom LIKE(QUSOBJD00)
Object Domain
D ObjCrtDatTim LIKE(QUSCDT02)
Create Date Time
D ObjChgDatTim LIKE(QUSCDT03)
Change Date Time
D Stg LIKE(QUSORAGE00)
Storage
D ObjCmpSts LIKE(QUSOBJCS00)
Object Compress Sts
D AllChg LIKE(QUSAC00)
Allow Change
D ChgPgm LIKE(QUSCBPGM00)
Changed By Program
D ObjAudVal LIKE(QUSOBJAV00)
Object Audit Value
D Reserved02 LIKE(QUSRSV208)
Reserved2
D MbrFil LIKE(QUSSFILN)
Source File Name
D MbrLib LIKE(QUSSFLN)
Source File Lib Name
D MbrNam LIKE(QUSSFMN)
Source File Mbr Name
D MbrChgDatTim LIKE(QUSSFUDT)
Source Upd Date/Time
D ObjCrtUsr LIKE(QUSCUP)
Creator User Profile
D SysObjCrt LIKE(QUSSOBJC)
System Object Create
D SysLvl LIKE(QUSSL)
System Level
D ObjCmp LIKE(QUSPILER)
Compiler
D ObjLvl LIKE(QUSOBJL00)
Object Level
D UsrChg LIKE(QUSUC)
User Changed
D LicPgm LIKE(QUSLPGM)
Licensed Program
D PTF LIKE(QUSPTF)
PTF
D APAR LIKE(QUSAPAR)
APAR
D PrmGrp LIKE(QUSPG)
Primary Group
D Reserved03 LIKE(QUSRSV300)
Reserved3
...
C* Open list of objects.
C EVAL OpnObjLstErr = OpnObjLst('*ALL':
C
LibLst(IdxLibLst):
C
'OBJL0400')
...
C* Retrieve next object from open list.
C EVAL RtvObjLstRtn = RtvObjLst(ObjLstPtr)
C*
C SELECT
C WHEN RtvObjErr = *ON
Error.
C EVAL ErrFlg = *ON
C*
C WHEN RtvObjEof = *OFF
Object found.
I hope this helps you to understand how this API can be used. We have
spent a lot of time creating sub-procedures over most of the commonly used
APIs. We have found this allows us to quickly and easily use system
functions.
David Morris
>>> <nigel.percy@pocruises.com> 04/15 3:16 AM >>>
David,
Many thanks for replying directly. (I'm on the digest version of
Midrange-L so it takes a while for the replys to filter through). I am
new to the concepts of pointers, I'll explain what I have been doing.
I am using QUSLOBJ to return a list of files in various libs. I then
use QUSPTRUS to return the pointer to this space. Then using the
following code I find the offset and size
d UserSpace DS Based(Pointer)
d Space 5000
d SpaceArray 1 OVERLAY(Space) Dim(5000)
d Offset 9B 0 OVERLAY(Space:125)
d Size 9B 0 OVERLAY(Space:133)
The code was copied from an example I found. The trouble I am having
is that if there are a large number of entries returned, The array
runs out of space.
As I see it the reason for using pointers is to avoid repeatly calling
QUSRTVUS with different offsets as the whole user space is loaded into
the array.
If I have got the concept completely wrong, please tell me. I look
forward to your reply
Nigel Percy
______________________________ Reply Separator
_________________________________
Subject: Re: ILE RPG & List API's
Author: MIME:dmorris@plumcreek.com at INTERNET
Date: 14/04/1998 18:37
Nigel,
You don't have to allocate any storage if you don't want to (except for the
heading area of the user space). There is an API to retrieve a pointer to
the
user space. You can add the offset length for entries to "retrieve" your
information
without really moving it. You need to declare a based structure that defines
the structure of the API's entries. These are usually defined in QSYSINC
with
the name of the list API. The API that retrieves a pointer to the beginning
of a us
er space is QUSPTRUS and it is very simple to use. The only tricky part is
pulling in the offset to the beginning of data and the entry lengths. This
information may depend on the API used to load the user space and should be
in
the list A
PI's documentation. The definition usually comes from QSYSINC/QRPGLESRC
QUSGEN format QUSH0100. The offset to the first entry is in QUSOLD.
David Morris
>>> <nigel.percy@pocruises.com> 04/14 8:32 AM >>>
Hi All,
Could someone give me some advice regarding using ILE RPG and list
API's via user spaces. As you know you can manipulate data in user
spaces via pointers in ILE RPG. If I going to be retrieving data via
an API into a user space and I have no idea how much data is going to
be returned, what do I set the Data Structure/Array Size to?
If I set it 'Really Big' this will obviously have a negative impact on
the amount of storage that the pgm uses.
You can't use dynamic allocation because I don't know how items are
going to be returned via the API.
The pointer method seems to be at a disadvantage when compared with
using the QUSRTVUS and incrementing the offset
Please someone tell me I got it wrong and that the pointer method is
the way to go.
Nigel Percy
_______________________________________________________________
Please note that the e-mail address for
P&O Cruises has changed to @pocruises.com
_______________________________________________________________
Please note that the e-mail address for
P&O Cruises has changed to @pocruises.com
+---
| This is the Midrange System Mailing List!
| To submit a new message, send your mail to MIDRANGE-L@midrange.com.
| To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: david@midrange.com
+---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.