× 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.



Looking at this reminds me of why I prefer to do most everything with RPG ... yuck!


Jon Paris

www.partner400.com
www.SystemiDeveloper.com

On Jul 9, 2019, at 12:33 PM, DrFranken <midrange@xxxxxxxxxxxx> wrote:

One example of the error return area for an API call:

DCL &ERR *CHAR 16 /* Err Information */
DCL &EBprv *UINT 4 STG(*DEFINED) DEFVAR(&ERR 1) /* Err Bytes provided */
DCL &EBavl *UINT 4 STG(*DEFINED) DEFVAR(&ERR 5) /* Err Bytes Available*/
DCL &EEid *CHAR 7 STG(*DEFINED) DEFVAR(&ERR 9) /* Err ID */

Here &ERR is the 'data structure' and the other three are subfields of &Err. Any of the variables can be read or updated and as expected any overlaying field changes as well.

DCL &Cinf *CHAR 112 STG(*BASED) BASPTR(&Cptr) /* Cartridge Info*/
DCL &CID *CHAR 6 STG(*DEFINED) DEFVAR(&Cinf 1 ) /* Cartridge ID */
DCL &VID *CHAR 6 STG(*DEFINED) DEFVAR(&Cinf 7 ) /* Volume ID */
DCL &LIBn *CHAR 10 STG(*DEFINED) DEFVAR(&Cinf 13) /* Tape Libr name*/
DCL &Tcat *CHAR 10 STG(*DEFINED) DEFVAR(&Cinf 23) /* Tape Category */
DCL &Tsys *CHAR 8 STG(*DEFINED) DEFVAR(&Cinf 33) /* Tape System */
DCL &Tden *CHAR 10 STG(*DEFINED) DEFVAR(&Cinf 41) /* Tape Density */
DCL &Cdat *CHAR 6 STG(*DEFINED) DEFVAR(&Cinf 51) /* Change Date */
DCL &Ctim *CHAR 6 STG(*DEFINED) DEFVAR(&Cinf 57) /* Change Time */
DCL &Cloc *CHAR 10 STG(*DEFINED) DEFVAR(&Cinf 77) /* Cartridge Loc */
DCL &ClcI *CHAR 1 STG(*DEFINED) DEFVAR(&Cinf 87) /* Location Ind */
/* ClcI = 0 In tape drive, 1 = Storage location */
DCL &Vst *CHAR 2 STG(*DEFINED) DEFVAR(&Cinf 88) /* Volume Status */
/* Vst = 01-Available, 02-Mounted, 03-not avail, 04-Ejected, */
* 05-Error, 06-inserted, 07-duplicate ID */
DCL &Oid *CHAR 17 STG(*DEFINED) DEFVAR(&Cinf 90) /* Owner ID */
DCL &WP *CHAR 1 STG(*DEFINED) DEFVAR(&Cinf 107) /* Write Prot */
/* WP = 0-NOT Write protected, 1-Write Protected. */
DCL &CIDs *CHAR 1 STG(*DEFINED) DEFVAR(&Cinf 109) /* Cart ID Source*/
/* CIDs = 0-volume ID is CID, 1-System Generated, 2-From Bar Code */
DCL &IEs *CHAR 1 STG(*DEFINED) DEFVAR(&Cinf 110) /* Imp/Exp Slot */
/* IEs = 0-Not in import export slot, 1-import export slot */
DCL &Mtyp *CHAR 2 STG(*DEFINED) DEFVAR(&Cinf 111) /* Media type(BC)*/

Here the data is as DS but it is located in memory where &Cptr (a pointer variable) points it to. So an API returns the base location and a long list of this repeating data. By changing the pointer offset for the data structure &Cinf all of the subfields change as well. This makes the operational code trivial, thus:

DOFOR &Cnum FROM(1) TO(&NCat) /* Loop through all available tapes */
CHGVAR %OFFSET(&Cptr) &Cofs

SELECT

WHEN (&WP *NE '0') THEN(DO)
/* Tape is write protected. Can't consider. */
ENDDO
WHEN (&Vst *EQ '03' *OR &Vst *EQ '04') THEN(DO)
/* Not avail or ejected. Can't consider. */
ENDDO

/* Additional code to consider tapes */

ENDSELECT

CHGVAR &Cofs (&Cofs + &LCat) /* Point to next cartridge *
ENDDO /* End of tape loop */


Does that help or confuse???


- Larry "DrFranken" Bolhuis

www.Frankeni.com
www.iDevCloud.com - Personal Development IBM i timeshare service.
www.iInTheCloud.com - Commercial IBM i Cloud Hosting.

On 7/9/2019 11:52 AM, David Gibbs via MIDRANGE-L wrote:
On Tue, Jul 9, 2019 at 10:48 AM DrFranken <midrange@xxxxxxxxxxxx> wrote:
Don't we get most of this with *DEFINED and *BASED variables and using
includes to pull the definitions in?
Not sure I follow you ... could you post an example?
david
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxx for any subscription related questions.

Help support midrange.com by shopping at amazon.com with our affiliate link: https://amazon.midrange.com


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.