LoginLogin

Detecting where PRINT is going to print to

Root / Programming Questions / [.]

PtcguyCreated:
Is there a way to tell where the PRINT command will print its text to? I'm asking because in my prime number generating program (PRIME), the printed prime numbers frequently wrap around the screen making them almost impossible to read.

Have you tried using the locate command

Locate doesn't work, since it will print the number starting at that point, regardless of pre-existing text. The prime numbers will be constantly increasing in size so I can't know beforehand how long they're going to be, although a simple function can take care of that. The disadvantage of using locate is that once I've reached the bottom of the screen, I can't shift up everything already on screen (if there is a way, please tell me) so I need to clear the whole screen, which makes pausing the program while it's running to see a whole screen of prime numbers rather difficult (especially with the low numbers).

You can tell how long a string is using LEN, and you can convert a number to a string using STR$. Also, LOCATE 0,29:PRINT will scroll the text screen up one line.

Use WAIT to slow down the printing of the numbers, that would be etremely useful.

If you just use PRINT without LOCATE, it will automatically scroll everything else upwards - however, there's no way to scroll back up to see the earlier info. I don't know what your needs are exactly, but if you need to generate a lot of data that you can then browse over at will, then you might consider writing into a PRG slot instead of printing to the screens. Take a look at PRGEDIT, PRGSET and PRGINS in the instruction list for more info.

Maybe use DIM to make a history of all the numbers

There is a new command (called SCROLL I think) that can scroll printed text on the screen.

There is a new command (called SCROLL I think) that can scroll printed text on the screen.
Indeed; Syntax: SCROLL A, B A=How many units the screen will move left or right, positive moving it right and vice versa B=How many units the screen will move up or down, positive moving it down and vice versa

Alright, thanks guys.

Alright, thanks guys.
You are so very welcome!

Alright, I've got a working engine for printing numbers (which never spill onto the next line). I've put it in PRIME and will upload soon.