|
Jim,
A user space is a system object of type *USRSPC. It is essentially
just an area of storage, with arbitrary user-defined contents. You
can use APIs to create, retrieve, change and delete a user space.
By far the easiest way to work with the data in a user space is to use
the QUSPTRUS API, to retrieve a pointer to the space. If you then
base a variable on the returned pointer, you can access the data in
the space through the variable. The only real drawback to this
approach is that locking is not implemented, so it is possible for two
users to change the same space at the same time.
Why use a user space instead of (say) a data area? For me, there are
a couple of reasons: First, the access through the QUSPTRUS interface
makes reading/writing the space trivial. Second, the space will be
dynamically resized by the system as required. Third, user spaces are
*way* faster. And finally, because there is no CHGUSRSPC command, it
is harder for someone to accidentally trash the contents of the space.
In a previous life, I wrote a dynamic trigger handler. This one
trigger program was added to all relevant files. Each file had a
corresponding user space, containing the names of the programs that
should be called by the generic trigger. The user space contained a
number of fields at the start -- offset to *BEFORE *UPDATE program
list; number of *BEFORE *UPDATE programs, offset to *AFTER *UPDATE
program list, number of *AFTER *UPDATE programs... (you get the idea)
followed by the lists of programs. The programs to both maintain and
read these user spaces were very straightforward, and extremely fast.
--
Paul
______________________________ Reply Separator _________________________________
Subject: Re: Text on report
Author: Jim Langston <jlangston@conexfreight.com> at INTERNET
Date: 21-06-00 9:53 am
Hmm... what exactly is a "user space"? I've heard mention of these,
but always thought they were the same thing as a User Data Structure
(UDS). Are they one in the same?
+---
| This is the RPG/400 Mailing List!
| To submit a new message, send your mail to RPG400-L@midrange.com.
| To subscribe to this list send email to RPG400-L-SUB@midrange.com.
| To unsubscribe from this list send email to RPG400-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.