|
kent.hellqvist@ibs.se wrote: > > Hi, has anyone used the QWCRSVAL API? I'm looking at the parameters > this API, and some of the datatypes are a bit confusing to me > (char(*)). Are there typedefs. described in any manual, which? > > Regards/ Kent Hellqvist Yes, that particular API is one of the more awkward ones to use :) Basically, in the phrase CHAR(*), the * can be replaced with ANY number. You can pass a variable thats 20 chars long, or 1000 chars long... usually, as in this case, you tell the API the length of the field in a seperate parameter. The same goes for the phrase "ARRAY(*) of BINARY(4)" The number of things in that array vary... In the case, you're telling it the number of system values that you'd like the value returned for, so you'll know how many elements that array will have... The other confusing thing about this particular API is that different system values will return different data types that are of different lengths... The way that I deal with this issue is by creating a sub-proc that simply copies the value returned by the API to a pointer thats passed as a parameter. Then when I'm writing my program that uses the API, I pass the address of a variable thats of the correct type for the system value that I'm retrieving... Here's a quick sample program... good luck! D GetSysVal PR 10I 0 D peSysVal 10A Const D peRtnVal * Value D SerialNo S 8A D SysLibl S 10A DIM(15) D LogSize S 10I 0 D Msg S 40A C if GetSysVal('QHSTLOGSIZ':%addr(LogSize))>0 c eval Msg = 'History Log Size' c Msg dsply LogSize c endif C if GetSysVal('QSRLNBR':%addr(SerialNo))>0 c eval Msg = 'Serial number' c Msg dsply SerialNo c endif C if GetSysVal('QSYSLIBL':%addr(SysLibl))>0 c eval Msg = 'System Library List' c Msg dsply c do 15 X 2 0 c if SysLibl(X) <> *blanks c SysLibl(X) dsply c else c Leave c endif c enddo c dsply Pause 1 c endif c eval *INLR = *On P*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ P* Retrieves a system value. P* Different system values return different data types, P* Please make sure you pass the correct type, and that P* It is long enough to contain the entire result... P* P* Returns 0 for failure, or 1 for success. P*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ P GetSysVal B EXPORT D GetSysVal PI 10I 0 D peSysVal 10A Const D p_RtnVal * Value D peRcvVar S 1A DIM(1000) D peRtnVal S 984A BASED(p_RtnVal) D peRVarLen S 10I 0 D peNumVals S 10I 0 D p_Offset S * D wkOffset S 10I 0 BASED(p_Offset) D dsErrCode DS D dsBytesPrv 1 4I 0 D dsBytesAvl 5 8I 0 D dsExcpID 9 15 D dsReserved 16 16 D dsExcpData 17 256 D p_SV S * D dsSV ds BASED(p_SV) D dsSVSysVal 10A D dsSVDtaTyp 1A D dsSVDtaSts 1A D dsSVDtaLen 10I 0 D dsSVData 984A c eval dsBytesPrv = 256 c eval dsBytesAvl = 0 c eval peSysValNm = peSysVal C CALL 'QWCRSVAL' 99 C PARM peRcvVar C PARM 1000 peRVarLen c PARM 1 peNumVals c PARM peSysValNm 10 c PARM dsErrCode c if dsBytesAvl > 0 or *IN99 = *On c return 0 c endif c eval p_Offset = %addr(peRcvVar(5)) c eval p_SV = %addr(peRcvVar(wkOffset+1)) c eval %subst(peRtnVal:1:dsSVDtaLen) = c %subst(dsSVData:1:dsSVDtaLen) c return 1 P E +--- | 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-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.