| 1 | <html><head><meta name="robots" content="index,follow"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 2 | <title>padRight$</title> |
| 3 | <style> |
| 4 | td { padding-left: 5pt; padding-right: 5pt; } |
| 5 | th { padding-left: 5pt; padding-right: 5pt; } |
| 6 | code { white-space: pre-wrap; } |
| 7 | dd { white-space: pre-wrap; } |
| 8 | </style> |
| 9 | </head><body bgcolor="#FFFFFF"> |
| 10 | |
| 11 | <table border=0 cellpadding=0 cellspacing=0><tr><td bgcolor="#CCCC00"><table border=4 cellpadding=9><tr><td align=middle bgcolor="#000000"><font face="Monaco,Courier" size=6 color="#999900"><b> |
| 12 | padRight$ |
| 13 | </b></font></table></table> |
| 14 | <p>A function that can be used in <a href="Formulas.html">Formulas</a>.</p> |
| 15 | <h2>Syntax and semantics</h2> |
| 16 | <dl> |
| 17 | <dt><b><code><font size=+1>padRight$</font></code></b> (<i><code><font size=+1>string$</font></code></i>, <i><code><font size=+1>minimumNewWidth</font></code></i> [, <i><code><font size=+1>pad$</font></code></i>]) |
| 18 | <dd>add characters (selected from <i><code><font size=+1>pad$</font></code></i>) to the right of <i><code><font size=+1>string$</font></code></i> until the result is at least as long as <i><code><font size=+1>minimumNewWidth</font></code></i>:</dd> |
| 19 | </dl> |
| 20 | <code> <a href="_assert_.html">assert</a> <b>padRight$</b> ("hello", 12, ".") = "hello......."<br></code> |
| 21 | <code> <a href="_assert_.html">assert</a> <b>padRight$</b> ("hello", 5, ".") = "hello"<br></code> |
| 22 | <p>If <i><code><font size=+1>pad$</font></code></i> is not given, the padding will be done with spaces:</p> |
| 23 | <code> <a href="_assert_.html">assert</a> <b>padRight$</b> ("hello", 12) = "hello "<br></code> |
| 24 | <p>No truncation takes place, so the resulting string may be longer than <i><code><font size=+1>minimumNewWidth</font></code></i>:</p> |
| 25 | <code> <a href="_assert_.html">assert</a> <b>padRight$</b> ("hello", 3) = "hello"<br></code> |
| 26 | <code> <a href="_assert_.html">assert</a> <b>padRight$</b> ("hello", -100) = "hello"<br></code> |
| 27 | <p>If <i><code><font size=+1>pad$</font></code></i> contains more than one character, the right edge of <i><code><font size=+1>pad$</font></code></i> is right-aligned to the resulting string, so that the result will look good if padding is used for visualizing columns:</p> |
| 28 | <code> <a href="_assert_.html">assert</a> <b>padRight$</b> ("hello", 12, ".-;)") = "hello-;).-;)"<br></code> |
| 29 | <code> <a href="_assert_.html">assert</a> <b>padRight$</b> ("goodbye", 12, ".-;)") = "goodbye).-;)"<br></code> |
| 30 | <p>There will be an error message if padding is required but no characters are to be found in <i><code><font size=+1>pad$</font></code></i>:</p> |
| 31 | <code> <a href="_asserterror_.html">asserterror</a> Empty pad string.<br></code> |
| 32 | <code> a$ = <b>padRight$</b> ("hello", 12, "")<br></code> |
| 33 | <h3>Links to this page</h3> |
| 34 | <ul> |
| 35 | <li><a href="Functions.html">Functions</a> |
| 36 | </ul> |
| 37 | <hr> |
| 38 | <address> |
| 39 | <p>© Paul Boersma 2024</p> |
| 40 | </address> |
| 41 | </body> |
| 42 | </html> |