user2824979
user2824979

Reputation: 21

How can i create files (automatically) through a vb.net program that act as input for other programs?

I have a program that uses some user input to automatically create files I need for an upload process. The files are a .bas (qbasic program) and a .lot (a voxco automaton file). The files are created perfectly, the syntax is flawless. When I try to run the batch files that start the basic program and the lot file stuff, it breaks down. The programs (voxco and basic) don't seem to know how to read the files. I'm at a loss. I don't think it is the encoding. I think my VB.net program is creating a text file with a ".lot" and ".bas" extension, and the two other programs don't know how to deal with that. But I have no idea how to create the proper files other than naming them .lot and .bas. Anyone have any experience with this?

Here's some of the code that creates the .LOT file:

'Create a copy of the old lot file
        My.Computer.FileSystem.CopyFile(LotFilePath & OldStudy & ".LOT", LotFilePath & "BackEnd\" & OldStudy & ".LOT")
        System.IO.File.Create(LotFilePath & "BackEnd\" & StudyID & ".LOT").Dispose()



        Dim LotText As String
        LotText = Text to put into LOT file
        Dim QuLines As String = Nothing
        Dim Reader As New StreamReader(LotFilePath & OldStudy & ".LOT")
        Dim SLine As String = Nothing
        While Not Reader.EndOfStream
            SLine = Reader.ReadLine()
            If SLine.StartsWith("*QU") Then
                QuLines = QuLines & SLine & vbCrLf
            End If
        End While
        LotText = LotText & QuLines

        Dim TempPath As String
        TempPath = LotFilePath & "BackEnd\" & StudyID & ".LOT"
        My.Computer.FileSystem.WriteAllText(TempPath, LotText, 0)

And here's the code that creates the BAS file:

Dim BasText As String = Nothing
        BasText = Text to input into BAS file
        TempPath = BasFilePath & StudyID & ".BAS"
        My.Computer.FileSystem.WriteAllText(TempPath, BasText, 0)

Upvotes: 2

Views: 1044

Answers (1)

xpda
xpda

Reputation: 15813

Here are some things to try:

  1. Make sure the Basic program has vbCrLf at the end of each line.
  2. Does qBasic require line numbers? (I don't remember)
  3. Try getting into qBasic and manually load the basic file generated by your application. Do you get a proper listing? What happens when you try to execute it?
  4. Enter the first few lines of the basic program in qBasic, then save it. Use a hex editor (such as hexedit) to compare this file with the application-generated basic file. If there is a difference you can fix it.
  5. If the basic file runs manually, then the problem may be with the batch file. Can you manually create the basic and voxco files and have them work with the batch file?

Upvotes: 2

Related Questions