Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pete's Dumb Idea of the Day!
#15
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


Attached Files
.bi   EDI_Data.BI (Size: 29.52 KB / Downloads: 6)
Tread on those who tread on you

Reply


Messages In This Thread
Pete's Dumb Idea of the Day! - by Pete - 10-21-2024, 07:53 PM
RE: Pete's Dumb Idea of the Day! - by TDarcos - 10-23-2024, 02:47 AM
RE: Pete's Dumb Idea of the Day! - by CharlieJV - 10-22-2024, 12:01 AM
RE: Pete's Dumb Idea of the Day! - by dano - 10-22-2024, 01:08 AM
RE: Pete's Dumb Idea of the Day! - by Pete - 10-22-2024, 05:55 AM
RE: Pete's Dumb Idea of the Day! - by bplus - 10-22-2024, 10:40 AM
RE: Pete's Dumb Idea of the Day! - by a740g - 10-22-2024, 11:46 AM
RE: Pete's Dumb Idea of the Day! - by Petr - 10-22-2024, 03:57 PM
RE: Pete's Dumb Idea of the Day! - by Pete - 10-23-2024, 01:01 AM
RE: Pete's Dumb Idea of the Day! - by SMcNeill - 10-23-2024, 03:54 AM
RE: Pete's Dumb Idea of the Day! - by Pete - 10-23-2024, 07:59 AM
RE: Pete's Dumb Idea of the Day! - by SpriggsySpriggs - 10-23-2024, 11:19 AM
RE: Pete's Dumb Idea of the Day! - by CharlieJV - 10-23-2024, 01:07 PM
RE: Pete's Dumb Idea of the Day! - by Pete - 10-23-2024, 05:37 PM
RE: Pete's Dumb Idea of the Day! - by CharlieJV - 10-23-2024, 08:09 PM
RE: Pete's Dumb Idea of the Day! - by Pete - 10-23-2024, 10:29 PM



Users browsing this thread: 13 Guest(s)