Over-write previously printed line

Discussion about the ZBasic language including the System Library. If you're not sure where to post your message, do it here. However, do not make test posts here; that's the purpose of the Sandbox.
Post Reply
pjc30943
Posts: 220
Joined: 01 December 2005, 18:45 PM

Over-write previously printed line

Post 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?
Paul
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Re: Over-write previously printed line

Post 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.
- Don Kinzer
Don_Kirby
Posts: 341
Joined: 15 October 2006, 3:48 AM
Location: Long Island, New York

Post 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
Post Reply