Gets or set the contents of a file to the value of a Data Element in the Data Segment.
Syntax:
Parameters:
Remarks:
When assigning a file object to the data element, the data stored to the data element is the contents of the physical file of the ediFile object. When retrieving a value as a file object, the value of the data element is stored to a temporary file, and the ediFile object of the temporary file is returned. The temporary file is deleted when the instance of the object is destroyed.
NOTE: If the data element has no value, this property will return an empty object or NULL.
The vElement and vSubElement parameters are variants whereby the identifier or the position can be passed. If an identifier is specified then it is passed as a string parameter; otherwise the position can be passed as a numeric parameter.
For example, the following statements are identical. The statements below gets a file value from a simple element "785" which is at position 5 of a data segment.
- Set oFile = oDataSegment.DataElementFileValue(5)
- Set oFile = oDataSegment.DataElementFileValue("785")
The following statements are identical and gets a file value from a component element "1565" at position 4 of the composite element "C050", which is at position 10 of a data segment.
- Set oFile = oDataSegment.DataElementFileValue(10, 4)
- Set oFile = oDataSegment.DataElementFileValue("C050", "1565")
- Set oFile = oDataSegment.DataElementFileValue(10, "1565")
- Set oFile = oDataSegment.DataElementFileValue("C050", 4)
Example 1: Getting the value
Dim oDataSegment As Fredi.ediDataSegment
Dim oFile As Fredi.ediFile
....
' Get first data segment in document.
Set oDataSegment = oEdiDoc.FirstDataSegment
' Get the BEG data segment.
Set oDataSegment = oDataSegment.GetDataSegmentByPos("\ISA\GS\ST\BEG")
' Get the file object containing the data element value.
Set oFile = oDataSegment.DataElementFileValue(5)
' Get the value from the file object.
MsgBox "Element Value: " & oFile.GetStringContent(EncodeType_Binary)
Example 2: Setting the value
Dim oDataSegment As Fredi.ediDataSegment
Dim oFile As Fredi.ediFile
Dim oFileSystem As Fredi.ediFileSystem
....
' Get file system.
Set oFileSystem = oEdiDoc.GetFileSystem
....
' Get first data segment in document.
Set oDataSegment = oEdiDoc.FirstDataSegment
' Get the BEG data segment.
Set oDataSegment = oDataSegment.GetDataSegmentByPos("\ISA\GS\ST\BEG")
' Set file object with file containing new data element value.
Set oFile = oFileSystem.GetFile(App.Path & "\FileValue.txt")
' Set the data element value from the file object.
Set oDataSegment.DataElementFileValue(5) = oFile
' Show new value of data element.
MsgBox "Element Value: " &oDataSegment.DataElementValueByPos("\ISA\GS\ST\BEG<373>")
Sample