Option Explicit

'J:\Eigene Dateien\Dokumente\Hannes\Visual Basic\csvtolatex\config.ctl
'Test.csv
'\LaTeXTest

Const version = "1.2"

Dim sPath, input, output, mode, title, msg, ende, options, comma
title = "csvtolatex configuration creator " & version
ende = True

sPath = InputBox("Please write here the full path and the name with extension of the configuration-file. Example: 'C:\user\documents\LaTeX\config.ctl'", title)

If InStr(sPath, ":\")   Then
       If InStr(Right(sPath, 4), ".ctl")       Then

       Else
               sPath = sPath + ".ctl"
       End If
Else
       ende = False
End If


input = InputBox("Please write here the name of the inputfile with extension like written in the documentation. Example: '\csv-tables\input.csv'", title)

If StrComp(input, "")   Then
Else
       ende = False
End If

If ende Then
       output = InputBox("Please write here the relative or absolute Path for the outputfiles. Example: '\LaTeX-tables\' If you want the path relative to your configuration file write 'config=' before the path. Example: 'config=\LaTeX-tables\'", title)


       mode = InputBox("Please write here weather 'text' for textmode or 'math' or nothing for mathmode", title)

       If InStr(mode, "nothing")       Then
               mode = ""
               msg = MsgBox("If you wanted mathmode by writing 'nothing' I have set it to blank, because nothing is no reserved word", 0, title)
       End If


       Dim Fso, sFile

       Set  Fso  =  CreateObject("Scripting.FileSystemObject")
       Set  sFile  =  Fso.CreateTextFile(sPath)

               sFile.WriteLine "input=" & input
       If StrComp(output, "")  Then
               output = "output=" & output
               sFile.WriteLine output
       End If
       If StrComp(mode, "")    Then
               mode = "mode=" & mode
               sFile.WriteLine mode
       End If

       options = InputBox("Please write here the option you choose. Example: 'nolines' to have no \hline at the end of the lines", title)

       If StrComp(options, "")   Then
               options = "options=" & options
               sFile.WriteLine options
       End If

       sFile.WriteLine InputBox("If you wish write here the comma/point replacement you want, if you do not want to replace it, just leave it out. Write >commatopoint< if you want to convert all commas to points, or >pointtocomma> if you want to have it the other way around", title)


       sFile.Close

       msg = MsgBox("I have written in: >" & sPath & "< input: >" & input & "< output: >" & output & "< and mode: >" & mode & "< I hope this is all right.", 0 , title)
Else
       msg = MsgBox("There has to be a correct configurationfilename with absolute path and at least a correct inputfilename. Your configurationfilepath and -name was: >" & sPath & "< And your inputfile was: >" & input & "<", 0, title)
End If