An NDoc Documented Class Library

Engine.SetMultiFieldData Method 

Save data to more than one field at a time in the given document.

public static ASERR SetMultiFieldData(
   ASFP file,
   ASDOC doc,
   DocType type,
   int num_fields,
   set_multi_field_data[] pdata
);

Parameters

file
The file handle returned by OpenASFile or OpenASFileEx.
doc
The handle of the document to save the data in.
type
The document type.
num_fields
The number of field to save to
pdata
A array to field info structures, see the definition of set_multi_field_data.

Return Value

Returns 0 if there was an error. Use GetLastASError to find out why. Returns 1 if this method succeeded.

Remarks

Call this method to save data to more than one field at a time in the given document.

Example

[C#]

ASFP asFileHandle = 0;
StringBuilder strError = new StringBuilder(1024);
ASERR asError = 0;
string result = "";

// Open File

asFileHandle = Engine.OpenASFile(@"C:\Inetpub\wwwroot\asNetSDKRegressionTest\google_news.ask", OpenFileHow.ASOF_READWRITE, OpenFileShare.ASOF_READWRITE);
if (asFileHandle == 0)
{
	Engine.ASErrorToString(Engine.GetLastASError(asFileHandle), strError, 1024);
	result += strError.ToString() + "\n";
}
StringBuilder strDocName = new StringBuilder(256);
ASDOC asDocument = 0;
asError = Engine.FirstDocWithName(asFileHandle, DocType.DT_DATA, ref asDocument, strDocName, 256);
if (asError == 0)
{
	Engine.CloseASFile(asFileHandle);
	throw new Exception("not able to get document");
}

// Do Primary action
set_multi_field_data[] fieldData = {new set_multi_field_data("To[", FieldDataType.FD_EXPAND_FIELD | FieldDataType.FD_REPLACE_CONTENT, FormatType.FF_TEXT, "you")};
try
{
	asError = Engine.SetMultiFieldData(asFileHandle, asDocument, DocType.DT_DATA, 1, fieldData);
} 
catch (Exception ex)
{
	Engine.CloseASFile(asFileHandle);
	throw new Exception("problem with SetMultiFieldData" + ex.Message);
}
if (asError == 0)
{	
	Engine.ASErrorToString(Engine.GetLastASError(asFileHandle), strError, 1024);
	result += "CloseASFile: " + strError.ToString() + "\n ";
}
asError = Engine.CloseASFile(asFileHandle);
if (asError == 0)
{
	Engine.ASErrorToString(Engine.GetLastASError(asFileHandle), strError, 1024);
	result += "CloseASFile: " + strError.ToString() + "\n ";
}
return result;
[VB.NET]
Dim aSFP As ASFP = aSFP.op_Implicit(0)
Dim stringBuilder1 As StringBuilder = New StringBuilder(1024)
Dim aSERR As ASERR = aSERR.op_Implicit(0)
Dim str1 As String = ""
aSFP = Engine.OpenASFile("C:\Inetpub\wwwroot\asNetSDKRegressionTest\google_news.ask", CType(2, OpenFileHow), CType(2, OpenFileShare))
If aSFP.op_Equality(aSFP, 0) Then
    Engine.ASErrorToString(Engine.GetLastASError(aSFP), stringBuilder1, 1024)
    str1 = String.Concat(str1, stringBuilder1.ToString(), Chr(10))
End If
Dim stringBuilder2 As StringBuilder = New StringBuilder(256)
Dim aSDOC As ASDOC = aSDOC.op_Implicit(CLng(0))
aSERR = Engine.FirstDocWithName(aSFP, CType(1, DocType), aSDOC, stringBuilder2, 256)
If aSERR.op_Equality(aSERR, 0) Then
    Engine.CloseASFile(aSFP)
    Throw New Exception("not able to get document")
End If
Dim Set_multi_field_datas1 As set_multi_field_data() = New set_multi_field_data() {New set_multi_field_data("To[", 536870920, 1, "you")}
aSERR = Engine.SetMultiFieldData(aSFP, aSDOC, CType(1, DocType), 1, Set_multi_field_datas1)
If aSERR.op_Equality(aSERR, 0) Then
    Engine.ASErrorToString(Engine.GetLastASError(aSFP), stringBuilder1, 1024)
    str1 = String.Concat(str1, "CloseASFile: ", stringBuilder1.ToString(), Chr(10) & " ")
End If
aSERR = Engine.CloseASFile(aSFP)
If aSERR.op_Equality(aSERR, 0) Then
    Engine.ASErrorToString(Engine.GetLastASError(aSFP), stringBuilder1, 1024)
    str1 = String.Concat(str1, "CloseASFile: ", stringBuilder1.ToString(), Chr(10) & " ")
End If
Dim str2 As String = str1
Return str2

See Also

Engine Class | askSam Namespace