ReadRecord Method
Reads the next input record.
C++ Syntax
HRESULT STDMETHODCALLTYPE ReadRecord(OUT VARIANT_BOOL *pbDataAvailable);
Script Syntax
bDataAvailable = ReadRecord();
Return Value
A Boolean value set to TRUE if a new input record has been read and is available for consumption, or FALSE if there are no more input records to return.
Remarks
- An implementation of the ReadRecord method would usually read a new data item from the input and store it internally, waiting for Log Parser to subsequently call the GetValue method multiple times to retrieve the input record field values.
-
The Boolean value returned by the ReadRecord method is used by Log Parser to determine
which custom input format methods will be called next.
If the method returns TRUE, signaling availability of an input record, Log Parser will call the GetValue method multiple times to retrieve the input record field values, followed by a new call to the ReadRecord method to read the next input record.
If the method returns FALSE, signaling the end of the input data, Log Parser will call the CloseInput method and release the custom input format COM object.
Examples
C++ example:
HRESULT CProcessesInputContext::ReadRecord(OUT VARIANT_BOOL *pbDataAvailable) { if( m_hSnapshot == INVALID_HANDLE_VALUE ) { // This is the first time we have been called // Get a shapshot of the current processes m_hSnapshot = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 ); if( m_hSnapshot == INVALID_HANDLE_VALUE ) { // Error return HRESULT_FROM_WIN32( GetLastError() ); } // Get the first entry if( !Process32First( m_hSnapshot, &m;_processEntry32 ) ) { DWORD dwLastError = GetLastError(); if( dwLastError == ERROR_NO_MORE_FILES ) { // No processes *pbDataAvailable = VARIANT_FALSE; return S_OK; } else { // Error return HRESULT_FROM_WIN32( GetLastError() ); } } else { // There is data available *pbDataAvailable = VARIANT_TRUE; return S_OK; } } else { // We have already been called before, and we have already taken a snapshot // Get the next entry if( !Process32Next( m_hSnapshot, &m;_processEntry32 ) ) { DWORD dwLastError = GetLastError(); if( dwLastError == ERROR_NO_MORE_FILES ) { // No more processes *pbDataAvailable = VARIANT_FALSE; return S_OK; } else { // Error return HRESULT_FROM_WIN32( GetLastError() ); } } else { // There is data available *pbDataAvailable = VARIANT_TRUE; return S_OK; } } }VBScript example:
Function ReadRecord() If m_nIndex >= UBound(m_objQFEArray) Then ' Enumeration terminated ReadRecord = False Else 'Advance m_nIndex = m_nIndex + 1 ReadRecord = True End If End Function
See also:
ILogParserInputContext InterfaceGetValue Method
Run Time Interaction
Custom Plugins