On 2011-06-13 16:54, Hockchai Lim wrote:
Yes, I've read some posts somewhere before saying that export variable is
not the best thing to use. Therefore, I've never try to use it. But to use
that feature, I would assume that PROGRAMA and PROGRAMD will need to somehow
bind to each other, no?....
About the only place I've used export for something similar is in an
application with a lot of configuration values that were retrieved in
the service module containing the data exports. However, I think you
could just declare the data value in a service module, export it, then
bind the service program containing the module. If I recall correctly,
there's no requirement to have a method in a service module. Both
programs would need to declare the variable with the import keyword.
You might also use the user space APIs. You retrieve a pointer to the
space object in each program, base a variable on the pointer, then just
use it as if it were local storage. You can either create the user space
on the fly in qtemp, or if you know there can only be one instance of
the app at a time, you can have a permanent user space object on disk,
and just use it. Either way, you still need to get the space pointer
though. From my ancient (pre-prototype) archives, the user space pointer
API (QUSPTRUS) looks like this:
/IF DEFINED(INCLUDEHDR)
*
-----------------------------------------------------------------------
* Retrieve Pointer to User Space API Interface Definitions
*
-----------------------------------------------------------------------
* Normal usage:
* -------------------------------
* D ... D-Specs
* /COPY QUSPTRUS
* D ... D-Specs
* C ... C-Specs
* /COPY QUSPTRUS
* C ... C-Specs
* C eval QP_SpaceName = SPACE_NAME
* C eval QP_SpaceLib = SPACE_LIB
* C call 'QUSPTRUS' PL_QUSPTRUS
* C if (E_BytesAvail > *ZEROS)
* C eval ErrMsg = E_MsgID
* C eval MsgDta = E_ExcptData
* C return
* C endif
* * Set the generic list header template to the start of the
data space
* C eval @QUSH0100 = @QP_SpacePtr
* C eval @QP_SpacePtr = *Null
*
-----------------------------------------------------------------------
/ENDIF
/IF NOT DEFINED(DQUSPTRUS)
/DEFINE DQUSPTRUS
/COPY DERRSTRUCT
D QP_QualSpace DS
D QP_SpaceName 10
D QP_SpaceLib 10
D @QP_SpacePtr S *
/ELSEIF NOT DEFINED(CQUSPTRUS)
/DEFINE CQUSPTRUS
C PL_QUSPTRUS plist
C parm QP_QualSpace
C parm @QP_SpacePtr
C parm E_ErrorStruct
/ENDIF
You can create the user space on the fly with the QUSCRTUS API:
/IF NOT DEFINED(DQUSCRTUS)
/DEFINE DQUSCRTUS
/IF DEFINED(INCLUDEHDR)
*
------------------------------------------------------------------------
* QUSCRTUS Create User Space Parameter Definitions
* Parameter Definitions and Parameter List
* -----------------------------------------
* * Typical usage:
*
* * D-Specs
* /COPY QUSCRTUS
* * ...
* * C-Specs
* /COPY QUSCRTUS
* * ...
* * Create a 1 MB user domain space in QTEMP
* C eval US_SpaceName = 'MYSPACE'
* C eval US_InlSize = 1024000
* C call 'QUSCRTUS' PL_QUSCRTUS
*
------------------------------------------------------------------------
/ENDIF
D US_QualSpace DS
* Space Name
D US_SpaceName 10
* Space Library (Name, *CURLIB)
D US_SpaceLib 10 Inz('QTEMP')
* Space extended attribute
D US_ExtAttrib 10
* Initial size of space in bytes (1-16776704)
D US_InlSize 10U 0 Inz
* Initial value of dataspace
D US_InlValue 1 Inz(X'00')
* Public Authority (*ALL, Authorization list name,
* *CHANGE, *EXCLUDE, *LIBCRTAUT, *USE
D US_PubAut 10 Inz('*ALL')
* Object text
D US_Text 50 Inz
* Replace existing object (*YES, *NO) An error is returned
* if the space already exists, and this value is *NO (Default).
D US_Replace 10 Inz('*NO')
* Object Domain (*DEFAULT, *SYSTEM, *USER)
D US_Domain 10 Inz('*DEFAULT')
* Transfer size. Number of storage pages to be transferred
* between main and auxilliary storage. (0-32) If 0 (default)
* the system will use the default size.
D US_TfrSize 10U 0 Inz(0)
* Optimum space alignment. (*OFF, *ON) If this value is
* *OFF, the maximum space size is 16776704. If it is *ON,
* the maximum size is 16773120. Default is *ON
D US_OptAlign N Inz(*ON)
/ELSEIF NOT DEFINED(CQUSCRTUS)
/DEFINE CQUSCRTUS
C PL_QUSCRTUS plist
C parm US_QualSpace
C parm US_ExtAttrib
C parm US_InlSize
C parm US_InlValue
C parm US_PubAut
C parm US_Text
C parm US_Replace
C parm E_ErrorStruct
C parm US_Domain
C parm US_TfrSize
C parm US_OptAlign
/ENDIF
As an Amazon Associate we earn from qualifying purchases.