Search code examples
eofti-basic

call "EOF" in Ti-83 BASIC


Is there an EOF operator in Ti-83 Basic like in many other languages, such as C? I know that some programmes terminate when the "On" button is pressed (much like the EOF operator, Ctrl+D, in *nix), but I haven't been able to figure out how this operation is assigned.

As a very bad example, say I have

:Prompt Str0
:While Str0 ≠ "EOF"
:Disp "This code works!"
:Prompt Str0
:End

I want it to print "This code works!" and then prompt for Str0 until I enter a key combo ("On" button, I'm guessing) that terminates the file.

Now of course there are other ways of expressing the code above that do not rely on EOF. I'm just trying to give a simple example of what a scenario in which EOF might be useful.


Solution

  • If you are looking for a way to get keypad input to end your program, there is no single function, but you can use getKey to write code to do it. Here is an example of how to make a program go until a certain key combination is entered, or the program is broken.

    :Disp "This code works!"
    :While getKey ≠ 21
    :End
    :While getKey ≠ 31
    :End
    :While getKey ≠ 45
    :End
    :Disp "Program ending"
    :Stop
    

    The above code displays "This code works!", then waits until 2nd, ALPHA, then CLEAR are pressed before displaying "Program ending" then quitting. If you are unfamiliar with the getKey function, I recommend this link. Good luck with your coding!