Example for VB.net and BRIZ (GUI GP_TERM.LIB)

This sample created only for explanation how to create connection, read the items and work with array of items.For more details see COM Example and other examples . Download solution.

For this example it is nessesary:
1 Start BRIZ
2 Login into account with GP_TERM.LIB
3 Start any program based on GP_TERM.LIB (PE, SPE, PEHELP, ADM.PRG, Funprg, Test.vb, example_com ...)
4 Start example or dedug example from VS2005

 

Every xxx_Click:
1 create object
2 Retrive data from server
3 Release object

In real, project creates object once.

    Private Sub button_lf_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button_lf.Click
        Dim str1 As String = "BRIZ"
        Dim gpConn1 As New GP_Term.Connector()
        Dim gpDoc1 As GP_Term.Document
        Dim obj1 As Object = Nothing
        Dim iTCLGetFlag As Integer = 0
        Dim objTCLRes As Object = Nothing

        gpDoc1 = gpConn1.GetTerminal(str1)
        gpConn1 = Nothing
        If (Not gpDoc1 Is Nothing) Then
            gpDoc1.ExecTCL("select md")
            While (gpDoc1.GetTCLResult(objTCLRes, iTCLGetFlag) < 0)
            End While
            gpDoc1.GetActiveList(obj1)
            gpDoc1 = Nothing
        End If
        If Not ((obj1 Is Nothing) Or (obj1 Is DBNull.Value)) Then
            Dim i As Integer

            listBox_lf.Items.Clear()
            i = 0
            While (i < UBound(obj1))
                listBox_lf.Items.Add(obj1(i))
                i = i + 1
            End While
        End If
    End Sub

    Private Sub button_lmd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button_lmd.Click
        Dim strConnect As String = "BRIZ"
        Dim gpConn As New GP_Term.Connector()
        Dim gpDoc As GP_Term.Document
        Dim arrDelims As Char() = Char.ConvertFromUtf32(1).ToCharArray()
        Dim objKeys As Object = Nothing, objRecs As Object = Nothing, objRec As Object
        Dim i As Integer, iFileHandle As Integer
        Dim lviTmp As ListViewItem

        gpDoc = gpConn.GetTerminal(strConnect)
        gpConn = Nothing
        If (Not gpDoc Is Nothing) Then
            iFileHandle = gpDoc.OpenPICKFile("md")
            If (iFileHandle >= 0) Then
                gpDoc.ReadKFromPICKEx(iFileHandle, -1, objRecs, objKeys)
                i = 0
                While (i < UBound(objRecs))
                    lviTmp = listView_md.Items.Add(objKeys(i).ToString())
                    objRec = objRecs(i).ToString().Split(arrDelims)
                    lviTmp.SubItems.Add(objRec(0).ToString())
                    If (UBound(objRec) > 0) Then lviTmp.SubItems.Add(objRec(1).ToString())
                    If (UBound(objRec) > 1) Then lviTmp.SubItems.Add(objRec(2).ToString())
                    If (UBound(objRec) > 2) Then lviTmp.SubItems.Add(objRec(3).ToString())
                    i = i + 1
                End While
                gpDoc.ClosePICKFile(iFileHandle)
            End If
            gpDoc = Nothing
        End If
    End Sub
End Class
        
        

Explanation:

Create objects and connect to provider

              Dim str1 As String = "BRIZ"
// default registration name. You should use unique name (for example ApplicationName:PortNumber)
        Dim gpConn1 As New GP_Term.Connector()
// declare and create Connector object
        Dim gpDoc1 As GP_Term.Document
// declare Provider object
        Dim obj1 As Object = Nothing
// declare object for array of items
        Dim iTCLGetFlag As Integer = 0
        Dim objTCLRes As Object = Nothing
// Declae and initialize array for Screen result of TCL command

        gpDoc1 = gpConn1.GetTerminal(str1)
// Initialize provider object
        gpConn1 = Nothing
// release connector object
              If (Not gpDoc1 Is Nothing) Then
// validate Provider object

Release Provider object

                    gpDoc = Nothing

Processing data exchange

1 Button "List files" (Actually, read items Id of entire md )
                   gpDoc1.ExecTCL("select md")
  // Execute TCL command 
                     While (gpDoc1.GetTCLResult(objTCLRes, iTCLGetFlag) < 0)
            End While
  // Waiting the result of TCL command 

                     gpDoc1.GetActiveList(obj1)
  // retrieve result into obj1

2 Button "list MD" (Actually, only Item ID and Attr. 1,2,3)
                    iFileHandle = gpDoc.OpenPICKFile("md")
  // Open server file "MD" 
                     If (iFileHandle >= 0) Then
  // Check result
                           gpDoc.ReadKFromPICKEx(iFileHandle, -1, objRecs, objKeys)
  //Read entire file (Items and keys). The best way is read file by items groups
                           i = 0
                While (i < UBound(objRecs))
  // loop till to upper bound of array 
  // It is possible convert array to araay of arrays

                              lviTmp = listView_md.Items.Add(objKeys(i).ToString())
                    objRec = objRecs(i).ToString().Split(arrDelims)
                    lviTmp.SubItems.Add(objRec(0).ToString())
                    If (UBound(objRec) > 0) Then lviTmp.SubItems.Add(objRec(1).ToString())
                    If (UBound(objRec) > 1) Then lviTmp.SubItems.Add(objRec(2).ToString())
                    If (UBound(objRec) > 2) Then lviTmp.SubItems.Add(objRec(3).ToString())
                    i = i + 1
                End While
// End loop
                gpDoc.ClosePICKFile(iFileHandle)
  // Close server file
                     End If

See also: COM in BRIZ.CHM documentation.

Actually, it is very easy.

   All remarks and offers direct to support service support@infotools.ru .

2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81