Computer Science Canada

How to open a ".txt" document in the Turing Execution Window.

Author:  nikoudov [ Tue Jan 16, 2007 9:55 am ]
Post subject:  How to open a ".txt" document in the Turing Execution Window.

You might ask your self this question...

How do I open and view a .txt (text) document?

Okay, so... if you are in a hurry and quickly in-need of a way to open and read a text document without exploring the Tutorials and understanding how it works, you are at the right link.




Here is the Turing Code:


Turing:

setscreen ("text") 
    % Variables needed to open the ".txt" document.
    var stream : int
    var Line : string

    % This procedure opens the file (The file is located in the same directory as this program).
    open : stream, "NameOfFile.txt", get

% Displays every line in the ".txt" document
    loop
        exit when eof (stream)
        get : stream, Line : *
        put Line
    end loop

% Closed the file
    close : stream[/i]



NOTE: make sure that the above code is not in a "loop" or "for" statement or else the file will not be displayed.

Cervantes added syntax tags


: