ClearImage DLID Reader Send comments on this topic.
Parse Method
See Also  Example
Text

Description

Parse input string

Syntax

Visual Basic
Public Function Parse( _
   ByRef Text As String _
) As Boolean

Parameters

Text

Example

Visual BasicCopy Code
' In VB6 Project menu Add Reference to:
' ClearImage COM Server
' ClearImageDLID Reader

Public Sub Read_2D(sFile As String)
  On Error GoTo except
   ' Create Reader
  Dim oReader As New ClearImageDLID.Reader
    ' Open image from file
  oReader.Image.Open sFile
    ' Find barcodes
  Dim Bc As CiBarcode
  Set Bc = oReader.Read2D
    ' Process Results
  If (Not Bc Is Nothing) Then MsgBox Parse_AAMVA(Bc.text)
  If (Bc Is Nothing) Then MsgBox "NO 2D Barcode"
  Exit Sub
except:
  MsgBox "ERROR: " & Err.Description
End Sub


Public Function Parse_AAMVA(text As String) As String
    ' Create Parser
  Dim oParser As New ClearImageDLID.ParserAAMVA
     ' Do Parsing
  If (oParser.Parse(text)) Then
    Dim s As String
     ' Display Results
    s = s & "FileType = " & oParser.FileType & vbCrLf
    s = s & "Issuer Identification Number = " & oParser.Issuer & vbCrLf
    s = s & "AAMVA Ver = " & oParser.AamvaVer & vbCrLf
    s = s & "Jurisdiction Ver = " & oParser.JurisdictionVer & vbCrLf
    s = s & "Number of Entries = " & oParser.NumberOfEntries & vbCrLf

    Dim d As ClearImageDLID.Element
    s = s & " == ELEMENTS ==" & vbCrLf
    For Each d In oParser.Elements
      If (d.isSet) Then
        s = s & d.Description & " [" & d.Id & "] = '" & d.Value & "'" & vbCrLf
      End If
    Next
    Parse_AAMVA = s
  Else
    Parse_AAMVA = oParser.Error
  End If
End Function


C#Copy Code
// In Visual Studio Project menu Add References to COM: 
//    ClearImageDLID Reader 
//    ClearImage COM Server 
 
using ClearImage; 
using ClearImageDLID; 
// ... 
 
static System.Threading.Mutex mut =  new System.Threading.Mutex();    // Prevents reentrancy 
private string Read_2D(string sFile) 
    { 
    try    { 
        mut.WaitOne(); 
             //  Create Reader 
        ClearImageDLID.Reader oReader = new  ClearImageDLID.Reader(); 
            //  Open image from file 
        oReader.Image.Open (sFile, 1); 
            //  Find barcodes 
        CiBarcode Bc = oReader.Read2D(); 
            // Process Results 
        if (Bc != null) return Parse_AAMVA(Bc.Text); 
        else            return ""; 
        } 
    catch (Exception ex) { 
        ShowError (ex); return "";} 
    finally    { 
        mut.ReleaseMutex(); 
        GC.Collect();} 
    } 
 
private string Parse_AAMVA(string text) 
    { 
    try    { 
            //  Create Parser 
        ClearImageDLID.ParserAAMVA oParser = new ClearImageDLID.ParserAAMVA(); 
            // Do Parsing 
        if (oParser.Parse(ref text)) 
            { 
            string s = ""; 
                //  Display Results 
            s = s + "FileType = " + oParser.FileType + Environment.NewLine; 
            s = s + "Issuer Identification Number = " + oParser.Issuer + Environment.NewLine; 
            s = s + "AAMVA Ver = " + oParser.AamvaVer + Environment.NewLine; 
            s = s + "Jurisdiction Ver = " + oParser.JurisdictionVer + Environment.NewLine; 
            s = s + "Number of Entries = " + oParser.NumberOfEntries + Environment.NewLine; 
 
            s = s + " == ELEMENTS ==" + Environment.NewLine; 
            foreach (ClearImageDLID.Element d in oParser.Elements) 
                { 
                if (d.isSet)  
                    s = s + d.Description + " [" + d.Id + "] = <" + d.Value + ">" + Environment.NewLine; 
                } 
            return s; 
            } 
        else 
            return oParser.Error; 
        }         
    catch (Exception ex) { 
        ShowError(ex); return "";} 
    } 

See Also