GetNumDocsInList method

The number of documents in the document list of the active folder is returned in the specified variable.

Method
short GetNumDocsInList(
VARIANT * pNumDocs)
Parameters
pNumDocs
Points to a variable to receive the number of documents in the document list of the active folder. On return, this variable is set to type VT_I4.
Description
The number of documents in the document list of the active folder is returned in the specified variable.
Return Value
Refer to return codes.
See Also
GetDocDisplayValues and OpenDoc methods

C/C + +

The following example creates a list box of the folder document list names and associated values and opens the document selected by a user.
 CArsOle * pArsCtrl;
 ArsOleName * pNames;
 ArsOleValue * pValues;
 CListBox * pDocList;
 char * pLine;
 short rc, k, opr, num_fields;
 long j, num_docs;
 int size;
 VARIANT vari;
   .
   .
 // During dialog initialization:

 rc = pArsCtrl->GetNumFolderDisplayFields( &vari );
 if ( rc != ARS_OLE_RC_SUCCESS )
   ERROR;
 num_fields = var.iVal;

 pNames = new ArsOleName[ max( num_fields, 1 ) ];
 rc = pArsCtrl->GetFolderDisplayFieldNames( (IUnknown*)pNames, num_fields );
 if ( rc != ARS_OLE_RC_SUCCESS )
   ERROR;

 rc = pArsCtrl->GetNumDocsInList( &vari );
 if ( rc != ARS_OLE_RC_SUCCESS )
   ERROR;
 num_docs = var.lVal;

 pValues = new ArsOleValue[ max( num_fields, 1 ) ];
   .
   .
   .
   .
 size = num_fields * ( sizeof(ArsOleName) + sizeof(ArsOleValue) + 5 );
 pLine = new char[ size ];
 for ( j = 0, pLine[0] = '\0'; j < num_docs; j++ )
 {
   rc = pArsCtrl->GetDocDisplayValues( j, pValues, num_fields );
   if ( rc != ARS_OLE_RC_SUCCESS )
     ERROR;

   for ( k = 0; k < num_fields; k++ )
   {
     strcat( pLine, pNames[k] );
     strcat( pLine, " = " );
     strcat( pLine, pValues[k] );
     if ( k < num_fields - 1 )
       strcat( pLine, ", " );
   }
   pDocList->InsertString( -1, pLine );
 }
 pDocList->SetCurSel( 0 );
   .
   .
 // During OK button processing:

 rc = pArsCtrl->OpenDoc( (long)pDocList->GetCurSel( ) , NULL, 0 );
 if ( rc != ARS_OLE_RC_SUCCESS )
   ERROR;
   .
   .

Visual Basic

Dim rc, count, i, j As Integer
Dim num_fields, num_docs As Variant
Dim Names() As String
Dim Line As String
Dim Temp As String
 .
 .
 .
rc = ArsOle.GetNumFolderDisplayFields(num_fields)
If rc <> ARS_OLE_RC_SUCCESS Then
    MsgBox "ERROR"
    End
End If

ReDim Names(num_fields -1)

For count = 0 To num_fields -1
    rc = ArsOle.GetFolderDisplayFieldName(count, Temp)
    Names(count) = Temp
Next count

rc = ArsOle.GetNumDocsInList(num_docs)
If rc <> ARS_OLE_RC_SUCCESS Then
    MsgBox "ERROR"
    End
End If

For j = 0 To num_docs -1
    For i = 0 To num_fields -1
        rc = ArsOle.GetDocDisplayValue(j, i, Temp)

        Line = Line + Names(i) + " = " + Temp
        If i < num_fields Then
            Line = Line + ", "
        End If
    Next i

    lbDocs.AddItem Line
Next j
 .
 .
 .
'During OK button processing:

rc = ArsOle.OpenDoc (lbDocs.List(lbDocs.ListIndex), "", 0)
If rc <> ARS_OLE_RC_SUCCESS Then
    MsgBox "ERROR"
    End
End If