ad_pad (public)

 ad_pad [ -left ] [ -right ] string length padstring

Defined in packages/acs-tcl/tcl/text-html-procs.tcl

Tcl implementation of the pad string function found in many DBMSs. One of the directional flags -left or -right must be specified and will dictate whether this will be a lpad or a rpad.

Switches:
-left (optional, boolean)
text will be appended left of the original string.
-right (optional, boolean)
text will be appended right of the original string.
Parameters:
string (required)
length (required)
padstring (required)
Returns:
padded string

Partial Call Graph (max 5 caller/called nodes):
%3 test_ad_pad ad_pad (test acs-tcl) ad_pad ad_pad test_ad_pad->ad_pad auth::password::email_password auth::password::email_password (private) auth::password::email_password->ad_pad packages/calendar/www/view-one-day-display.tcl packages/calendar/ www/view-one-day-display.tcl packages/calendar/www/view-one-day-display.tcl->ad_pad template::widget::dateFragment template::widget::dateFragment (public) template::widget::dateFragment->ad_pad template::widget::numericRange template::widget::numericRange (public) template::widget::numericRange->ad_pad

Testcases:
ad_pad
Source code:
    if {!($left_p ^ $right_p)} {
        error "Please specify single flag -left or -right"
    }
    if {$length < 1 || ![string is integer -strict $length]} {
        error "length ($length) must be an integer > 0"
    }

    set slength [string length $string]
    set padlength [string length $padstring]
    set repetitions [expr {int(($length - $slength) / $padlength) + 1}]
    set appended [string repeat $padstring $repetitions]
    incr length -1

    if {$left_p} {
        set string [string range $appended$string end-$length end]
    } else {
        set string [string range $string$appended 0 $length]
    }

    return $string
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: