2

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)
  • From what I remember, the qbasic files are just ascii encoding so you should be able to open/edit/create in notepad or the like. The extention is not really important so it's not that. Can you show code on how you "start the basic program" and explain what you mean by "it breaks down"? Do you get an error or something? – Steve Sep 27 '13 at 21:31
  • I'm afraid I don't have access to those files right now, but the code that starts the qbasic program is simply "path\qbasicexecutable /run \path\.basfile". It is a msdos batch file. When the qbasic line runs, the qbasic program opens (usually it runs in the background) and says something about an expression missing (sorry I know that isn't very helpful!) and stalls. Once I exit that, a similar line in the batch file starts the voxco application, which starts up, but doesn't load the file that the lot file should tell it to do. It immediately ends and the batch file moves on to the next item. – user2824979 Sep 27 '13 at 22:13
  • Great information, leads me to my next question (sorry, no answer yet). Does your path for LotFilePath or BasFilePath have any spaces or special character in them? – Steve Sep 27 '13 at 22:21

1 Answers1

2

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?
xpda
  • 15,585
  • 8
  • 51
  • 82
  • Very good suggestions. I can't try or answer any of them until Monday except for 2, the basic files do not require numbers. Thanks! – user2824979 Sep 28 '13 at 20:57
  • The hex editor shows the files to be exactly the same, between one created through my program and one copied from an older file (the latter works in the batch file). The carriage return and line feed is correct in my program. – user2824979 Sep 30 '13 at 11:47
  • Actually the hex editor worked - there was a section that doesn't appear in the actual file if you open it in notepad, above the actual text, and the code for that is slightly different between the two files (manually created and automatically created files). When I copy from one to the other the batch file will run the basic program properly. I can't yet get the lot file edited properly. So how do I make my program create the file properly? – user2824979 Sep 30 '13 at 12:16
  • That extra section at the beginning of the file probably identifies the text encoding type, or the byte order marks. The definition of "properly" is what is expected in the lot file. If you want to output precisely what is in the string LotText, you can convert the string lotText to a byte array and use System.IO.File.WriteAllBytes(filename, b), where b is a byte array. – xpda Sep 30 '13 at 19:11