Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
12 years ago

Backspace character in System Console

I am testing some memory using System Console and I would like to make a simple progress bar which will show current progress. For that I would need a backspace character.

The Tcl interpreter from Centos 7 works as expected:


$ tclsh
% puts $tcl_version
8.5
% puts "abc\bd"
abd

But System Console gives this:


% puts $tcl_version
8.5
% puts "abc\bd"
abcd

Is there any way I can delete current characters or maybe whole line in System Console?

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Probably not. System Console is a very crippled console interface which I believe is based on Jacl (a Java TCL interpreter).

    You might be better off looking at the Dashboard widgets and see if you can use a progress indicator there.

    Cheers,

    Dave
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    The solution is so simple that I am almost ashamed to post it. You don't have to delete anything if you dont print anything, so for a very simple progress bar it is enough to print a character on the right iterations.

    Here is the code:

    
    set BAR_LEN 50
    # ##############################################################################
    #  Puts top line
    proc put_top_line { } {
    	global BAR_LEN	
    	puts -nonewline "|"
    	for {set i 0} {$i < $BAR_LEN} {incr i} {
    		puts -nonewline "-"
    	}
    	puts -nonewline "|\n"
    }
    # ##############################################################################
    #  Puts#  to fill the progress bar, should be called every loop iteration
    proc put_filler {cur max} {
    	global BAR_LEN	
    	if {  } { 
    		puts -nonewline "|"
    	} elseif {  } { 
    		puts -nonewline "|\n"
    	} else {
    		set curValue 
    		set nextValue 
    		if {  } {
    			puts -nonewline "#"
    		}
    	}	
    }
    # ##############################################################################
    #  Test
    put_top_line
    for {set i 0} { $i < 1000 } { incr i } {
    	put_filler $i 999
    	after 10
    }