×
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.
On 10/30/13 7:21 AM, Charles MARTIN wrote:
I wish i could do some reflection using RPGLe.
By reflection, I mean :
'The process or mechanism of determining the capabilities of an
object at run-time.'
Imagine you have this datastructure :
D DS_Format DS Qualified Based(pDS_Format)
D Type 20I 0 Inz(1)
D Label 50A Inz('myLabel')
D Description 5000A Inz('myDescription')
With a reflection api, I could do this :
Reflection_ListSubfields(DS_Format);
=> return this array : { 'Type', 'Label', 'Description' }
And then, I could do :
Reflection_GetSubfield(DS_Format : 'Label');
=> return 'myLabel'
I wish i could do this too :
Reflection_GetSubfieldType(DS_Format : 'Label');
=> return 'A'
Reflection_GetSubfieldLength(DS_Format : 'Label');
=> return 50
Reflection_GetSubfieldPrecision(DS_Format : 'Type');
=> return 0
With this, I expect I could do something like this (with some little
work) :
SerializeXml(DS_Format); //I build xml with one line of code !
And get :
<DS_Format>
<Type>1</Type>
<Label>myLabel</Label>
<Description>myDescription</Description>
</DS_Format>
And conversely with DeserializeXml(myXml);
Reflection would help me to build really cool apis.
Is there any way ?
Have you looked at what of that the Dump Module Variables
(QteDumpModuleVariables) API could provide?
http://pic.dhe.ibm.com/infocenter/iseries/v7r1m0/topic/apis/QTEDMPMV.htm
"...
The Dump Module Variables (QteDumpModuleVariables) API is used to get a
list of all the variable names and current values of those variables.
Variable values may only be requested if an active call stack entry for
the module specified exists in the job in which this API is called.
Values existing in program static or automatic storage are not
accessible by this API unless the program has a current call stack
entry. All variables that were defined by the compiler and stored in the
module HLL symbol table will be returned. This API supports the ILE CL,
ILE COBOL, and ILE RPG compilers.
The module for which variable information is being requested must
contain debug data. See the debug view (DBGVIEW) parameter of the Create
RPG Module (CRTRPGMOD), Create COBOL Module (CRTCBLMOD), or Create CL
Module (CRTCLMOD) command. It is *not necessary that* the job in which
the program is running be *in debug mode* to use this API.
Variable names and, optionally, their values will be provided within the
block in which they were declared. This API does not guarantee that
those variables are returned in any particular order within the block.
...
_Data option_
INPUT; BINARY(4)
The content of the information returned for the module. The
possible values are:
0 Variable names only.
1 Variable names and current values in default character format
(the type associated with the variable will be used in determining the
format of the value returned).
2 Variable names, the current values in default character format,
and the current values in hex format.
..."
Later references in the docs mention "the default value", but surely
they intend to imply [with that apparent shorthand] the "current values
in default character format".
As an Amazon Associate we earn from qualifying purchases.