Empty Lines

Created by CecilWesterhof.

I use tcl mostly for command-line tools. Often I want to output several empty lines. For this I created the following proc:

proc emptyLines {{lines 3}} {
    if {![string is integer -strict $lines]} {
        error "lines should be an integer ($lines)"
    }
    if {$lines < 0} {
        error "lines cannot be negaative ($lines)"
    }
    puts -nonewline [string repeat \n $lines]
}

As always: comments, tips and questions are appreciated.


PYK 2018-06-07: All the input checking in this routine could be considered bad style, as it is unnecessary. string repeat already behaves reasonably if $count is a negative number. Also, this routine could have been placed somewhere on an existing page. It isn't significant enough to justify a new page. Furthermore, there isn't anything substantive enough about this example to warrant being placed anywhere on the wiki at all. Examples already exist to cover what is illustrated here.