2068 Tutorial: Open# Close#

Authors

Publication

Pub Details

Date

Pages

See all articles from T-S Horizons n12

Using the OPEN # and CLOSE # Commands on the TS 2068

Many people who use the 2068 have generally no idea what the commands OPEN# and CLOSE# are for and what they can do. These commands were intended for use with the Microdrives, but we can use them an entirely different way.

By using the OPEN# command you open up what is called a ‘stream’, or the line the data uses to get somewhere. You have 16 streams (0-15) which can be used. The last one (16) is for the 2068’s own use. The parameters for the OPEN# command are as follows:

OPEN #nn, a$

where nn is any number (0-15) and a$ is either “k”, “s”, or “p” (“k” being the keyboard, “s” the screen, and “p” the printer). Normally, streams 0 and 1 both point to “k”, stream 2 points to “s”, and stream 3 points to “p”, OK, you are probably confused by now. Let me now explain what all this means in English.

For starters, I’ll define more fully the meaning of the “k”, “s”, and “p” parameters. “k” stands for keyboard, but on your screen it’s the bottom 2 lines (where all the INPUTs are and the error codes are printed). “s” stands for screen and accesses the top 22 lines of the display. “p” 1s your printer or data port. You can also access a stream by using “PRINT#nn;n#$” or “INPUT#nn;n$” (or “n”). (Note: nn can, only be “1” in the input case). When you do a normal PRINT, you are using stream 2 (pointing to “s”). When you do an INPUT, you are using stream 0 (pointing to “k”). And when you do an LIST you are using stream 3 (pointing to “p”).

OK. Now I’ll explain how to use all this in sensible way. For temporary use of a stream in a print command, use a PRINT# statement. PRINT#3 will go to the printer, PRINT#3 or 1 will go to the bottom 2 lines of your screen. Incidentally, an PRINT command does the exact same as the PRINT#3 command did.

Here’s how the computer translates the commands you give it:

LPRINT same as PRINT #3 
PRINT same as PRINT #2

You use an OPEN# command to permanently open up a stream (until you close it). If you are typing in a program and you want to test it say it has out, and say it has some parts where it prints data out to a printer (1ike a word processor), and you don’t want to waste printer paper.

OPEN #3, "s"

This will now make all the commands using stream 3 (LLIST and LPRINT) go to the screen. Or, if you want to do the reverse and you want everything to go to the printer instead of the screen, you do:

OPEN #2,  "p"

This will send all the data that is supposed to go to the screen to printer.

If you want to open up a stream for your own use, you can:

OPEN #nn,a$

So, 1f you want to use stream 4 to go to the printer, you just OPEN# it up and tell it to go to the printer with “p”.

Finally, if you want, lets say stream 2 to return to normal (after you made it go to the printer), just do:

CLOSE #2

This will close it up and return to normal.

Commands using stream 0 or 1 (“k”)

  • INPUT

Commands using stream 2 (“s”)

  • PRINT
  • LIST

Commands using stream 3 (“p”)

  • LPRINT
  • LLIST

Equivalents

  • LPRINT = PRINT #3;
  • LLIST = OPEN #2, “p”: LIST
  • PRINT = PRINT #2;
  • LIST = OPEN #3, “s”:LLIST
  • PRINT = LPRINT #2;

Go ahead and experiment with these commands. They can be very useful in your programs.

Products

 

Media

 

Image Gallery

Source Code

Scroll to Top