Attribute VB_Name = "Module1"
Option Explicit
Option Base 0

Public Declare Sub data_conv Lib "esys.dll" (ByVal data_name As String, _
ByVal data_file As String, ByVal xml_file As String, _
ByVal xsl_file As String, ByVal xdr_file As String, _
ByVal n As Long, ByVal m As Long, ByVal del_type As Long, ByVal v_bound As Double, _
ByVal head As Long, ByVal name_ptr As Long, v_type As Long, _
n_cat As Long, cat_val As Long, ByVal max_cat As Long, info As Long)
 
Public Declare Sub list_names Lib "esys.dll" (ptr As Long, _
ByVal n As Long, ByVal i As Long, ByVal i_name As String)

Public Declare Sub free_list Lib "esys.dll" (ptr As Long, _
ByVal n As Long)

Public var_type() As Long, cat_val() As Long, n_cat() As Long
Public var_name() As String
Public n As Long, m As Long, var_num As Long, in_del As Long
Public head As Long, disp_lst As Long
Public in_miss As Double, data_set As Long, v_bound As Double
Public data_file As String, xml_file As String, xsl_file As String, xdr_file As String
Public work_dir As String, data_name As String
Public opt_file As String, opt_in_file As String
Public run_from_menu As Long, drive_set_up As String
Public give_opt_file As Long, full_path As Long

Public Sub set_var_list()
Dim i As Long
var_num = 0
set_var_form.var_list.Clear
For i = 0 To m - 1
    set_var_form.var_list.AddItem (var_name(i))
Next i
End Sub

Public Function get_cat_vals(input_line) As Long
Dim numlist As String, numstr As String
Dim i As Long, j As Long, k As Long, l As Long
Dim ival As Long, p As Long, r As Long
numlist = LTrim(input_line)
l = Len(numlist)
For i = 1 To l
    k = InStr(i, numlist, " ", 1)
    If k = 0 Then
        Exit For
    Else
        Mid(numlist, k, 1) = ","
    End If
Next i
k = l
p = 1
i = 0
While p <= l
    ival = Val(Right(numlist, k))
    cat_val(i + 100 * var_num) = ival
    numstr = Trim(Str$(ival))
    r = Len(numstr)
    j = InStr(p, numlist, numstr, 1)
    If j <> 0 Then
        p = j + r
        i = i + 1
    Else
        p = p + 1
    End If
    k = l - p
Wend
get_cat_vals = i
End Function

Public Sub view_xml()
Dim launch_browser As String, disp_file As String, linetxt As String
Dim chunk_file As String
Dim i As Long, k As Long
Dim RetVal
chunk_file = work_dir & "\chunk.xml"
Open xml_file For Input As #3
Open chunk_file For Output Shared As #4
k = 5000 / m + 4
If k > n Then
    k = n + 3
Else
    k = k + 3
End If
For i = 1 To k
    Line Input #3, linetxt
    Print #4, linetxt
Next i
Print #4, "</esys_data>"
Close #3
Close #4

launch_browser = """c:\Program Files\Internet Explorer\IEXPLORE.EXE""" & " " & chunk_file
RetVal = Shell(launch_browser, vbNormalFocus)

End Sub
