Page 1 of 1

Over-write previously printed line

Posted: 15 September 2009, 16:24 PM
by pjc30943
Is there a terminal command supported in zbasic to print pending characters at the start of the current line? I.e., displaying a changing number in place without entering to a new line for each update.
I know this is not supported by debug.print, but are there any COM1 tricks?

Re: Over-write previously printed line

Posted: 15 September 2009, 16:54 PM
by dkinzer
pjc30943 wrote:Is there a terminal command supported in zbasic to print pending characters at the start of the current line?
It all depends on what "terminal" you're using to view the output. Some terminal programs will move the cursor to the beginning of the line when they receive a carriage return (&H0d) and move to the next line when they receive a line feed (&H0a). The ZBasic IDE, however, does not do this. Rather, it treats a carriage return as an end-of-line character just as it does a linefeed. A linefeed immediately following a carriage return is ignored so the net effect is that CR, LF and CR-LF are all equivalent.

Posted: 15 September 2009, 17:49 PM
by Don_Kirby
I've done quite a bit of work using Hyperterminal and ZBasic. Most terminal emulation software (hyperterminal included) is actually emulating a DEC VT100/VT220 terminal. As such, you are welcome to use any number of escape codes to manipulate the screen/cursor/text.

In effect, you need only change your method of control. If the processor cannot output the correct formatting, then use the receiving end's abilities to achieve the same effect. I've used this method for menu driven applications written in ZBasic with excellent results. It's simply a matter of defining a few constants that contain the appropriate escape codes and embedding them in the debug.print statements.

Unrelated to your actual question, but worth mentioning here; be cautious when using debug.print in application code. There's a reason why it starts with 'debug'. A better method would be to open a com channel and write directly to the channel's output queue.

-Don Kirby