Chapter Contents

Previous

Next
PEEKC

PEEKC



Stores the contents of a memory address into a character variable

Category: Special


Syntax
Arguments
Details
Comparisons
Examples
Example 1: Listing ASCB Bytes
Example 2: Creating a DATA Step View
See Also

Syntax

PEEKC(address<,length>)

Arguments

address
specifies the memory address.

length
specifies the data length.
Default: 8, unless the variable length has already been set (by the LENGTH statement, for example)
Range: 1 to 32,767


Details

If you do not have access to the memory storage location that you are requesting, the PEEKC function returns an "Invalid argument" error.


Comparisons

The PEEKC function stores the contents of a memory address into a character variable. The PEEK function stores the contents of a memory address into a numeric variable.


Examples

Example 1: Listing ASCB Bytes

The following example, specific to the OS/390 operating environment, uses both PEEK and PEEKC, and prints the first four bytes of the Address Space Control Block (ASCB).

data _null_;
   length y $4;
      /* 220x is the location of the ASCB pointer */
   x=220x; 
   y=peekc(peek(x));
   put 'y= ' y;
run;

Example 2: Creating a DATA Step View

This example, specific to the OS/390 operating environment, also uses both the PEEK and PEEKC functions. It creates a DATA step view that accesses the entries in the Task Input Output Table (TIOT). The PRINT procedure is then used to print the entries. Entries in the TIOT include the three components outlined in the following list. In this example, TIOT represents the starting address of the TIOT entry.
TIOT+4 is the DDname. This component takes up 8 bytes.
TIOT+12 is a 3-byte pointer to the Job File Control Block (JFCB).
TIOT+134 is the volume serial number (volser) of the data set. This component takes up 6 bytes.
Here is the program:

   /* Create a DATA step view of the contents    */
   /* of the TIOT. The code steps through each   */
   /* TIOT entry to extract the DDname, JFCB,    */ 
   /* and volser of each DDname that has been    */ 
   /* allocated for the current task. The data   */
   /* set name is also extracted from the JFCB.  */
  
data save.tiot/view=save.tiot;
   length ddname $8 volser $6 dsname $44;
      /* Get the TCB (Task Control Block)address */ 
      /* from the PSATOLD variable in the PSA    */
      /* (Prefixed Save Area).  The address of   */ 
      /* the PSA is 21CX. Add 12 to the address  */
      /* of the TCB to get the address of the    */
      /* TIOT. Add 24 to bypass the 24-byte      */  
      /* header, so that TIOTVAR represents the  */ 
      /* start of the TIOT entries.              */

   tiotvar=peek(peek(021CX)+12)+24;

      /* Loop through all TIOT entries until the */
      /* TIOT entry length (indicated by the     */
      /* value of the first byte) is 0.          */
         
   do while(peek(tiotvar,1));

      /* Check to see whether the current TIOT   */
      /* entry is a freed TIOT entry (indicated  */
      /* by the high order bit of the second     */
      /* byte of the TIOT entry). If it is not   */
      /* freed, then proceed.                    */
            
      if peek(tiotvar+1,1)NE'l.......'B then do;
         ddname=peekc(tiotvar+4);
         jfcb=peek(tiotvar+12,3);
         volser=peekc(jfcb+134);
            /* Add 16 to the JFCB value to get  */ 
            /* the data set name.  The data set */
            /* name is 44 bytes.                */

         dsname=peekc(jfcb+16);
         output;
         end;

         /* Increment the TIOTVAR value to point */
         /* to the next TIOT entry. This is done */
         /* by adding the length of the current  */ 
         /* TIOT entry (indicated by first byte  */ 
         /* of the entry) to the current value   */
         /* of TIOTVAR.                          */

      tiotvar+peek(tiotvar,1);
   end;

      /* The final DATA step view does not       */ 
      /* contain the TIOTVAR and JFCB variables. */

   keep ddname volser dsname;
run;

     /* Print the TIOT entries.                  */
proc print data=save.tiot uniform width=minimum;
run;
In the PROC PRINT statement, the UNIFORM option ensures that each page of the output is formatted exactly the same way. WIDTH=MINIMUM causes the PRINT procedure to use the minimum column width for each variable on the page. The column width is defined by the longest data value in that column.

See Also

CALL Routine:

CALL POKE

Functions:

ADDR
PEEK


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.