Computer Science Canada

Turing file opening, assert condition is false

Author:  weird [ Thu Oct 15, 2020 1:43 pm ]
Post subject:  Turing file opening, assert condition is false

What is it you are trying to achieve?
I am trying to open and display a .txt document


What is the problem you are having?
I am trying to open a file, but it always says assert condition is false. I even copied my teachers example code, and it didn't work for me


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>

Turing:


var streamnumber : int

open : streamnumber, "NewText.txt", get

assert streamnumber > 0

var line : string

loop
    exit when eof(streamnumber)
    get : streamnumber, line
    put line
end loop

close : streamnumber




Please specify what version of Turing you are using
4.11

Author:  scholarlytutor [ Fri Oct 30, 2020 10:50 am ]
Post subject:  RE:Turing file opening, assert condition is false

If your assert condition is false, then Turing isn't even reading the other code. It stops on line 3.

There are two possibilities. The obvious one is to make sure your file is actually called NewText.txt, which is case sensitive. Otherwise, it won't open.

Second, the Turing file needs to be in exactly the same folder as NewFile.txt. So first of all, make sure your Turing program is actually saved to the computer, and in the same folder as NewText.txt.

If neither of those options work, feel free to message again and provide me with any other information you have, such as whether you're trying this at home or on a school computer.


: