beautypg.com

Example 6-3, Reading records from a data file – HP NonStop G-Series User Manual

Page 128

background image

Creating a Custom Measurement Application

Measure User’s Guide 520560-003

6- 16

Reading Counter Records From a Data File

Example 6-3. Reading Records From a Data File (page 1 of 2)

DEFINE RECORD^LENGTH = $DBL($LEN(DISC^DEF))#;
LITERAL TRUE = -1,
FALSE = 0;
INT .EXT RECORD^BUF[0:32767], ! space in extended segment
.EXT READ^PTR, ! buffer pointer
.EXT RECORD^PTR(DISC^DEF) !record pointer
DFNAME[0:11] := ["$SYSTEM MEASURE DISCDATA"],
DFNUM,
BUFSIZE,
BYTESRET := 0,
ERROR,
NUM^OF^RECORDS,
I;
INT(32) SPACE^AVAILABLE := 65536D,
TOTAL^BYTES := 0D;
FIXED FIRSTCALL := 0F; ! initialize firstcall to zero
STRUCT DESCRIPTOR(DEVICE^DESC);
! Open the data file for read access only.

IF ERROR := MEASOPEN(DFNAME,DFNUM,FALSE,TRUE)
THEN ... ! handle error
! Initialize the descriptor to describe all disks and
! initialize buffer pointer.

DESCRIPTOR.TYPE := DISC^T;
DESCRIPTOR.LEN := $LEN(DEVICE^DESC);
DESCRIPTOR.CPU^NUMBER := ALL;
DESCRIPTOR.CHNL := ALL;
DESCRIPTOR.CTL := ALL;
DESCRIPTOR.UNIT := ALL;
DESCRIPTOR.DEVICE^NAME ':=' "$* ";
@READ^PTR := @RECORD^BUF;
! Read in counter records until firstcall is zero. In a
! DO loop, first calculate the unused space in the extended
! segment, using the bytesret parameter returned by the
! last MEASREAD call. Set the buffer size to 32000 or to
! the unused space, whichever is smaller. Then call
! MEASREAD. Finally, adjust the buffer pointer and
! increment the total byte count by the number returned
! in bytesret.