$FiStat: Difference between revisions
m (1 revision) |
m (1 revision) |
||
Line 14: | Line 14: | ||
<p class="syntax"><section begin="syntax" />%STRING = $FiStat(stat_list, file_num) | <p class="syntax"><section begin="syntax" />%STRING = $FiStat(stat_list, file_num) | ||
<section end="syntax" /></p> | <section end="syntax" /></p> | ||
<p | <p>%STRING is made up of binary data, the first 4 bytes of which is an error code. If the error code is negative, %STRING will only be 4 bytes long.</p> | ||
Revision as of 00:37, 26 October 2012
Retrieve file's statistics into string
Most Sirius $functions have been deprecated in favor of Object Oriented methods. There is no OO equivalent for the $FiStat function.
This function allows retrieval of a specific file's statistics into a string.
The $FiStat function accepts two arguments and returns a string made up of an error code and returned statistics.
The first argument is a string of blank-delimited words indicating the statistics to be returned. The length of each returned statistic is always a multiple of 4 bytes. This facilitates the use of $StatD $StatD with the returned string. For more information on available statistics, see the SirMon User's Guide.
The second argument is the file number of the file for which data is to be returned.
Syntax
<section begin="syntax" />%STRING = $FiStat(stat_list, file_num) <section end="syntax" />
%STRING is made up of binary data, the first 4 bytes of which is an error code. If the error code is negative, %STRING will only be 4 bytes long.
The data returned by $FiStat is binary, the first 4 bytes of which contain a return code. If the return code is negative, only 4 bytes are returned. If the return code is positive, it contains a number of milliseconds that the online has been up. This provides a convenient number for calculating rates for the statistics.
With a positive return code, the next 10 bytes contain the blank-padded file name, followed by 2 bytes that contain the binary file number. This means that the actual data starts at offset 16 (byte number 17) in the result string.
-5 - Required parameter not specified -12 - Invalid parameter (argument 2 > NUSERS, or invalid name in stat_list) -13 - STAT not linked in -14 - Result string would be longer than 255 bytes -15 - File no longer open
The following program displays some totals for file 0 (always CCATEMP).
B %DATA IS STRING LEN 255 %DATA = $FiStat('DKIO CFRCONF CFRQUEU', 0) IF $LEN(%DATA) = 4 THEN PRINT '$FISTAT ERROR... RC = ' WITH - $UNBIN(%DATA) STOP END IF PRINT 'FILENAME = ' WITH $SUBSTR(%DATA, 5, 10) PRINT 'DKIO = ' WITH - $UNBIN( $SUBSTR(%DATA, 17, 4) ) PRINT 'CFRCONF = ' WITH - $UNBIN( $SUBSTR(%DATA, 21, 4) ) PRINT 'CFRQUEU = ' WITH - $UNBIN( $SUBSTR(%DATA, 25, 4) ) END