$FiStat: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
(Correction to length of stats returned)
 
(29 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{DISPLAYTITLE:$FiStat}}
{{DISPLAYTITLE:$FiStat}}
<span class="pageSubtitle"><section begin="desc" />Retrieve file's statistics into string<section end="desc" /></span>
<span class="pageSubtitle">Retrieve file's statistics into string</span>


<p class="warning">Most Sirius $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for the $FiStat function is [[to be entered]].</p>
<p class="warn"><b>Note: </b>Many $functions have been deprecated in favor of Object Oriented methods. There is no OO equivalent for the <var>$FiStat</var> function.</p>


This function allows retrieval of a specific file's statistics into a string.  
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==
==Syntax==
<p class="syntax"><section begin="syntax" /> %STRING = $FiStat(stat_list, file_num)
<p class="syntax"><span class="term">%string</span> = <span class="literal">$FiStat</span>(<span class="term">stat_list</span>, <span class="term">file_num</span>)
<section end="syntax" /></p>
<p class="caption">$FiStat Function
</p>
</p>
<p class="caption">%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>


===Syntax terms===
<table>
<tr><th>%string</th>
<td>A string of data. If the string is exactly four bytes, it contains a binary [[#Return codes|error code]].
<p>
Otherwise, the first four bytes contain the unsigned binary number of milliseconds that the Online has been up. This provides a convenient number for calculating rates for the statistics. </p>
<p>
The next ten bytes contain the blank-padded file name, then follows two bytes containing the binary file number. This means that the actual data starts at offset 16 (byte number 17) in the result string.</p></td></tr>
<tr><th>stat_list</th>
<td>a string of blank-delimited words indicating the statistics to be returned. The length of each returned statistic is always four bytes.  The first statistic in the stat list will be at byte number 17, the second at byte number 21 and so on. This facilitates the use of <var>[[$StatD]]</var> with the returned string. For more information about available statistics, see <var class="product">[[File statistics displayed in SirMon]]</var>. </td></tr>


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.
<tr><th>file_num</th>
<td>The file number of the file for which data is to be returned.</td></tr>
</table>


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.<p>
===Return codes===
-5 - Required parameter not specified
<p class="code"> -5   Required parameter not specified
-12 - Invalid parameter (argument 2 > NUSERS,
-12   Invalid parameter (argument 2 > NUSERS, or invalid name in stat_list)  
or invalid name in stat_list)
-13   STAT not linked in
-13 - STAT not linked in
-14   Result string would be longer than 255 bytes
-14 - Result string would be longer than 255 bytes
-15   File no longer open
-15 - File no longer open
</p>
<p class="caption">$FiStat return codes
</p>
</p>


 
==Example==
 
The following program displays some totals for file 0 (always CCATEMP).
The following program displays some totals for file 0 (always CCATEMP).
<p class="code"> B
<p class="code">Begin
%data IS STRING LEN 255
%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)
%data = $FiStat('DKIO CFRCONF CFRQUEU', 0)
PRINT 'DKIO = ' WITH -
IF $Len(%data) = 4 THEN
$UNBIN( $SUBSTR(%DATA, 17, 4) )
PRINT '$FISTAT ERROR... RC = ' WITH $Unbin(%data)
PRINT 'CFRCONF = ' WITH -
STOP
$UNBIN( $SUBSTR(%DATA, 21, 4) )
END IF
PRINT 'CFRQUEU = ' WITH -
$UNBIN( $SUBSTR(%DATA, 25, 4) )
   
   
END
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
</p>
</p>
<p class="code">
<ul>
<li>&SFUNC


==<b id="auth"></b>Products authorizing {{PAGENAMEE}}==
<ul class="smallAndTightList">
<li>[[List of $functions|Sirius functions]]</li>
<li>[[SirMon]]</li>
</ul>
</ul>
</p>
<p class="caption">Products authorizing $FiStat
</p>


[[Category:$Functions|$FiStat]]
[[Category:$Functions|$FiStat]]

Latest revision as of 22:35, 4 August 2021

Retrieve file's statistics into string

Note: Many $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.

Syntax

%string = $FiStat(stat_list, file_num)

Syntax terms

%string A string of data. If the string is exactly four bytes, it contains a binary error code.

Otherwise, the first four bytes contain the unsigned binary number of milliseconds that the Online has been up. This provides a convenient number for calculating rates for the statistics.

The next ten bytes contain the blank-padded file name, then follows two bytes containing the binary file number. This means that the actual data starts at offset 16 (byte number 17) in the result string.

stat_list a string of blank-delimited words indicating the statistics to be returned. The length of each returned statistic is always four bytes. The first statistic in the stat list will be at byte number 17, the second at byte number 21 and so on. This facilitates the use of $StatD with the returned string. For more information about available statistics, see File statistics displayed in SirMon.
file_num The file number of the file for which data is to be returned.

Return codes

-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

Example

The following program displays some totals for file 0 (always CCATEMP).

Begin %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

Products authorizing $FiStat