Attribute VB_Name = "GtVar"
Option Explicit
Public GtoolPath As String

Sub GtoolViewVariable(ByVal varname As String)
    Call Shell("command.com /C " & GtoolPath & "\gtview.bat " & varname, vbNormalFocus)
'    Dim output As Collection
'    Dim result As String
'    result = GetShellList(GtoolPath & "\gtview.exe " & varname, output)
'    Dim line As Variant
'    Dim alloutput As String
'    alloutput = ""
'    For Each line In output
'        alloutput = alloutput & Chr(13) & Chr(10) & line
'    Next line
'    If (alloutput <> "") Then MsgBox alloutput
End Sub

Sub GtoolVariableList(ByVal filename As String, varlist As Collection)
    Call GetPipeList(GtoolPath & "\gtlist.exe " & filename, varlist)
End Sub

Sub GtoolAttributeList(ByVal varname As String, attrlist As Collection)
    Call GetPipeList(GtoolPath & "\gtlist.exe " & varname, attrlist)
End Sub

Sub GtoolLinkList(ByVal varname As String, linkList As Collection)
    Dim links As String
    links = GtoolAttribute(varname & ":gt_structure_member")
    Call StringSplit(links, " ", linkList)
End Sub

Function GtoolLinkVarname(ByVal basevar As String, ByVal link As String) As String
    GtoolLinkVarname = GtoolAttribute(basevar & ":gt_structure_link_" & link)
End Function

Sub GtoolDeleteAttribute(ByVal var As String, ByVal attr As String)
    Dim attrname As String
    attrname = attr
    If (Mid(attr, 1, 1) = ":") Then Mid(attrname, 1, 1) = " "
    Dim result As String
    result = ShellWait(GtoolPath & "\gtattr " & var & " -delete=" & attrname)
    If Dir(result) <> "" Then Kill result
End Sub

Sub GtoolSetAttributeS(ByVal var As String, ByVal attr As String, ByVal value As String)
    Dim attrname As String
    attrname = attr
    If (Mid(attr, 1, 1) = ":") Then Mid(attrname, 1, 1) = " "
    Dim result As String
    result = ShellWait(GtoolPath & "\gtattr " & var & " " & attrname & "=" & value)
    If Dir(result) <> "" Then Kill result
End Sub

Function GtoolAttribute(ByVal attrurl As String) As String
    Dim list As Collection
    Call GetPipeList(GtoolPath & "\gtprint.exe " & attrurl, list)
    If list.Count > 1 Then
        MsgBox attrurl & "---" & list.Item(1)
    ElseIf (list.Count = 1) Then
        GtoolAttribute = list.Item(1)
    Else
        GtoolAttribute = ""
    End If
End Function

Function GtoolVariableClass(ByVal varname As String) As String
    Dim class As String
    class = UCase(GtoolAttribute(varname & ":gt_structure_class"))
    Select Case (class)
    Case "FRAME", "FIGURE", "CONTOURS", "LINE", "AXIS", "VARIABLE"
        GtoolVariableClass = class
    Case Else
        GtoolVariableClass = "VARIABLE"
    End Select
End Function
