Hmm, it seems like we left out the documentation for the EDX WriteObjects method in our docs. I guess most of our EDXs are read-only so most haven't run into this issue yet. We'll have to fix that.
In any case, I looked up how EViews calls WriteObjects and what get's passed in and what is expected back:
Basically, if an EViews STORE command is called for multiple objects (whether multiple names are specified or a name pattern is used), then WriteObjects will be called instead of the normal WriteObject.
WriteObjects takes the following parameters:
Code: Select all
Public Sub WriteObjects(ByRef errors As Object, _
ByRef objectIds As Object, _
ByVal attr As Object, _
ByVal vals As Object, _
ByVal ids As Object, _
ByVal overwriteMode As EViewsEdx.WriteType) Implements EViewsEdx.IDatabase.WriteObjects
objectIds,
attr,
vals, &
ids are similar to the parameters in WriteObject, but in WriteObjects these parameters represent
an array of each associated value. For example,
WriteObject::objectId is normally a single string name, but
WriteObjects::objectIds is an array of string names.
WriteObject::vals is an array of values for the object, but
WriteObjects::vals is an array of an array of values (2 dimensional). Basically, whatever value is being passed into WriteObject, WriteObjects will get as an array of those same values, one for each object.
overwriteMode is the same as in WriteObject.
errors is the only new property and is designed to let your WriteObjects method report back potential multiple errors, one for each object. It is initially an empty value when passed in, but if you need to report an error, you'll have to initialize it as an array with the same number of elements as the objectIds array, then set the error code at the corresponding index for the object that you're currently working on. This error value should be the error code that you would normally throw as a COMException in a WriteObject method, for example:
Code: Select all
Public Sub WriteObject(ByRef objectId As String, _
ByVal attr As Object, _
ByVal vals As Object, _
ByVal ids As Object, _
ByVal overwriteMode As EViewsEdx.WriteType) Implements EViewsEdx.IDatabase.WriteObject
Dim lsFilePath As String = msDatabaseId & "\" & LCase(objectId) & ".xml"
Select Case overwriteMode
Case EViewsEdx.WriteType.WriteProtect
'if the file already exists, don't overwrite it...
If System.IO.File.Exists(lsFilePath) Then
Throw New COMException("", EViewsEdx.ErrorCode.RECORD_NAME_IN_USE)
End If
To be clear, don't throw a COMException from WriteObjects if you only need to report an error for a single object, instead put the appropriate error code into the errors array (you can still throw a COMException if you run into a big issue that affects all of the objects). Once you return a non-empty errors array, EViews will loop thru it and report each problem back to the user.