$Pad: Difference between revisions

From m204wiki
Jump to navigation Jump to search
(Automatically generated page update)
 
m (add link)
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<p>The $PAD function allows padding to the left with a designated character. The $PAD function takes three arguments and returns a character string of the length specified by the value of the third argument. The resulting string contains the first argument, right-justified, and padded with the character indicated in the second argument. The length argument is rounded if it is not an integral value. For example:  </p>
<p>
<p class="code">$PAD('55449825','0',9) equals '055449825'
The <var>$Pad</var> function allows padding to the left with a designated character. <var>$Pad</var> works exactly like <var>[[$PadR]]</var>, with the exception that <var>$Pad</var> pads to the left while <var>$PadR</var> pads to the right. </p>
$PAD('123.65','*',8) equals '**123.65'
 
$PAD('123.65','*',7.66) equals '**123.65'  
<p class="note"><b>Note:</b> Many $functions have been superseded by [[Object oriented programming in SOUL|SOUL OO]] methods. The [[Right (String function)]] provides a left-padding feature similar to <var>$Pad</var>. </p>
<p>
The <var>$Pad</var> function takes three arguments and returns a character string of the length specified by the value of the third argument. The resulting string contains the first argument, right-justified, and padded with the character indicated in the second argument. The length argument is rounded if it is not an integral value. </p>
 
==Examples==
<p class="code">$pad('55449825','0',9) equals '055449825'
$pad('123.65','*',8) equals '**123.65'
$pad('123.65','*',7.66) equals '**123.65'  
</p>
</p>
<ul>
<ul>
<li>If the value of the length argument is greater than 255, 255 is used. </li>
<li>If the value of the third (length) argument is greater than 255, 255 is used. </li>
</li>
 
<li>If the value of the length argument is not greater than zero, a null string is returned.</li>
<li>If the value of the length argument is not greater than zero, a null string is returned.</li>
</li>
 
<li>If the second argument contains more than one character, the first character in the string is the one used for padding. For example:</li>
<li>If the second argument contains more than one character, the first character in the string is the one used for padding. For example:
<p class="code">$PAD('123.65','*4',8) equals '**123.65'   
<p class="code">$pad('123.65','*4',8) equals '**123.65'   
</p></li>
</p></li>
</ul>
</ul>
[[Category:SOUL $functions]]
[[Category:SOUL $functions]]

Latest revision as of 19:15, 7 October 2016

The $Pad function allows padding to the left with a designated character. $Pad works exactly like $PadR, with the exception that $Pad pads to the left while $PadR pads to the right.

Note: Many $functions have been superseded by SOUL OO methods. The Right (String function) provides a left-padding feature similar to $Pad.

The $Pad function takes three arguments and returns a character string of the length specified by the value of the third argument. The resulting string contains the first argument, right-justified, and padded with the character indicated in the second argument. The length argument is rounded if it is not an integral value.

Examples

$pad('55449825','0',9) equals '055449825' $pad('123.65','*',8) equals '**123.65' $pad('123.65','*',7.66) equals '**123.65'

  • If the value of the third (length) argument is greater than 255, 255 is used.
  • If the value of the length argument is not greater than zero, a null string is returned.
  • If the second argument contains more than one character, the first character in the string is the one used for padding. For example:

    $pad('123.65','*4',8) equals '**123.65'