Attribute VB_Name = "Module11"
Dim VarValue As String
Public CommaCount As Integer
Dim FileNum As Integer
Dim firststring As String
Public NameVal() As String
Public s As SIMAN
Dim OneOutLine As String

Public Sub ModifyValues()
On Error GoTo NoFile

FileNumOut = FreeFile
home = Arena.ActiveModel.Path
For d = 1 To Len(home)
        Char = Mid(home, d, 1)
        If Char = Chr(92) Then  'chr(92)=\
            lastslash = d
        End If
    Next d

    rootdir = Left(home, lastslash)
    
desiredfile = rootdir & "Read.txt"
Open desiredfile For Input As #FileNumOut
    Line Input #FileNumOut, OneOutLine
    If OneOutLine <> "" Then
        For t = 1 To Len(OneOutLine)
            Query = Mid(OneOutLine, t, 1)
            If Query = Chr(44) Then 'if the character is a comma
                CommaCount = CommaCount + 1
            End If
        Next t
        CommaCount = CommaCount + 1
        Close #FileNumOut
        ReDim NameVal(1, CommaCount)
    
        FileNumFree = FreeFile
        Open desiredfile For Input As #FileNumFree
        pass = 1
        Do Until EOF(FileNumFree)
            Line Input #FileNumFree, tempinput
            If tempinput <> "" Then
                If CommaCount = 1 Then
                    NameVal((pass - 1), 1) = tempinput
                Else
                    length = Len(tempinput)
                    For t = 1 To Len(tempinput)
                        charcomma = Mid(tempinput, t, 1)
                        If charcomma = Chr(44) Then
                            word = word + 1
                            If word = 1 Then
                                tempcomma = 0
                            End If
                            NameVal((pass - 1), word) = Mid(tempinput, tempcomma + 1, t - tempcomma - 1)
                            remainder = Right(tempinput, length - t)
                            tempcomma = t   'this way the value of tempcomma is that of the value of t at the last comma
                        End If
                    Next t
                    NameVal((pass - 1), CommaCount) = remainder
                    word = 0
                End If
                pass = pass + 1
            End If
        Loop
    'Close #FileNumFree
    pass = 0

    For r = 1 To CommaCount
        Arena.ActiveModel.SIMAN.VariableArrayValue(Arena.ActiveModel.SIMAN.SymbolNumber(NameVal(0, r))) = NameVal(1, r)
    Next r
    CommaCount = 0
    pass = 0

    End If
    Close #FileNumFree
Exit Sub

NoFile:
    If Err.Number = 53 Then
    'Else
    '    Arena.ActiveModel.End
    End If
Exit Sub

End Sub

