Inspect Manual

High-Level Inspect Commands
Inspect Manual429164-006
6-66
Examples
Using FOR with FORMAT and PIC
When you use the FOR clause with the FORMAT or PIC clauses, the FOR clause
determines how much data to display and the FORMAT or PIC clause determines
how to format the data.
Examples
The FOR clause examples are based on this TAL source code.
1. This example displays struct^x, i^arr, str, and str^blen without any special
formatting.
2. This example displays the first four doublewords of struct^x.
3. This example displays the first eight words of i^arr in octal (note that % appears
only if the value exceeds eight).
#1 ?SYMBOLS,NOLIST
#2
#3 STRUCT struct^def (*);
#4 BEGIN
#5 INT i;
#6 STRING s[0:29];
#7 END;
#8
#9 STRUCT struct^x ( struct^def );
#10
#11 PROC example MAIN;
#12 BEGIN
#13 STRING .ptr;
#14 INT str^blen;
#15 STRING .str[0:25];
#16 INT .i^arr[0:10];
#17
#18 struct^x.i ':=' 16 * [ 0 ];
#19 struct^x.s ':=' "This is example number one" -> @ptr;
#20 struct^x.i := @ptr '-' @struct^x.s;
#21
#22 i^arr ':=' [ 0, 2, 6, 14, 30, 62, 126, 254, 510, 1022, 2046
];
#23 str ':=' "Example text number two" -> @ptr;
#24 str^blen := @ptr - @str;
#25 END;
-PROGRAM-DISPLAY struct^x
STRUCT^X =
I = 26
S[0] = "This is example number one" ?0 ?0 ?0 ?0
-PROGRAM-DISPLAY i^arr
I^ARR[0] = 0 2 6 14 30 62 126 254 510 1022 2046
-PROGRAM-DISPLAY str,str^blen
STR[0] = "Example text number two" ?0 ?0 ?0, STR^BLEN = 23
-PROGRAM-DISPLAY struct^x FOR 4 DOUBLES
STRUCT^X = 1725544 1769152617 1931502968 1634562156
-PROGRAM-DISPLAY i^arr FOR 2 QUADS IN OCTAL
I^ARR[0] = 0 2 6 %16 %36 %76 %176 %376