10-23-2024, 11:19 AM
(This post was last modified: 10-23-2024, 11:25 AM by SpriggsySpriggs.)
Here's an example of how I like loading my data:
Code: (Select All)
Sub loadData (DataName As String, DataArray() As String)
'$Include:'EDI_Data.BI'
Dim As Unsigned Long i, lowerbound
lowerbound = LBound(DataArray)
i = lowerbound
Dim As String EDI
Select Case UCase$(DataName)
Case "SEPARATORS"
Restore Separators
Case "HEADER"
Restore Header
Case "TRAILER"
Restore Trailer
Case "DETAILSEGMENTS"
Restore DetailSegments
Case "LOOPS"
Restore Loops
Case "DOCUMENTS"
Restore Documents
Case "VERSIONS"
Restore Versions
Case "DOCUMENTTYPES"
Restore DocumentTypes
End Select
Read EDI
While EDI <> "EOD"
ReDim Preserve DataArray(lowerbound To UBound(DataArray) + 1)
DataArray(i) = EDI
i = i + 1
Read EDI
Wend
ReDim Preserve DataArray(UBound(DataArray) - 1)
End Sub
Code: (Select All)
Function isKnownDoc%% (DocType As String)
ReDim As String Docs(0)
loadData "Documents", Docs()
Dim As Long i
For i = LBound(Docs) To UBound(Docs)
If Docs(i) = DocType Then
isKnownDoc = -1
Exit Function
End If
Next
End Function
Function isKnownVersion%% (Version As String)
ReDim As String Versions(0)
loadData "Versions", Versions()
Dim As Long i
For i = LBound(Versions) To UBound(Versions)
If Versions(i) = Version Then
isKnownVersion = -1
Exit Function
End If
Next
End Function
Function docFriendlyName$ (DocType As String)
ReDim As String DocumentTypes(0)
loadData "DocumentTypes", DocumentTypes()
Dim As Long i
For i = LBound(DocumentTypes) To UBound(DocumentTypes)
If Left$(DocumentTypes(i), 3) = DocType Then
docFriendlyName = Mid$(DocumentTypes(i), 5)
Exit Function
End If
Next
End Function
Tread on those who tread on you