$Center: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
mNo edit summary
Line 2: Line 2:
<span class="pageSubtitle"><section begin="desc" />Center string<section end="desc" /></span>
<span class="pageSubtitle"><section begin="desc" />Center string<section end="desc" /></span>


<p class="warning">Most Sirius $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for the $Center function is [[to be entered]].</p>
<p class="warning">Most Sirius $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for the $Center function is the [[Center (String function]] or alias [[Centre (String function)]].</p>


This function builds a string of an indicated length containing a centered input string.  
This function builds a string of an indicated length containing a centered input string.  
Line 10: Line 10:
The first argument is the string to be centered.  
The first argument is the string to be centered.  


The second argument is the length of the output string. If this argument is negative or greater than 255, the request is cancelled. Omitting this argument invokes a special usage of $CENTER, as described at the end of this section.  
The second argument is the length of the output string. If this argument is negative or greater than 255, the request is canceled. Omitting this argument invokes a special usage of $CENTER, as described at the end of this section.  


The third argument is a pad character to be used for centering the result string. This is an optional argument and defaults to blank.
The third argument is a pad character to be used for centering the result string. This is an optional argument and defaults to blank.
Line 36: Line 36:
sets %JUNK to <tt>'---PAGE TITLE----'</tt>.  
sets %JUNK to <tt>'---PAGE TITLE----'</tt>.  


There is also an alternate usage for $CENTER, if the second argument (<i>length</i></i> is omitted. In this case, the third argument is ignored, and the first argument must be of the form:
There is also an alternate usage for $Center, if the second argument (<i>length</i></i> is omitted. In this case, the third argument is ignored, and the first argument must be of the form:
<p class="code"> lenpstring
<p class="code"> lenpstring
</p>
</p>
Line 47: Line 47:
<tr><th>string</th>
<tr><th>string</th>
<td>The string to be centered; this can be from 1 to 251 bytes in length.
<td>The string to be centered; this can be from 1 to 251 bytes in length.
</td></tr></table>
</td></tr>
</table>
 
If this form of $Center is used and any of the above restrictions are not met, the value returned by $Center is a single digit '1'. Note that this error return value is indistinguishable only to the valid invocation $Center('001p1'), where <i>p</i> is any pad character.
If this form of $Center is used and any of the above restrictions are not met, the value returned by $Center is a single digit '1'. Note that this error return value is indistinguishable only to the valid invocation $Center('001p1'), where <i>p</i> is any pad character.
<ul class="smallAndTightList">
<ul class="smallAndTightList">
<li>[[Sirius functions]]</li>
<li>[[Sirius functions]]</li>
Line 58: Line 61:
<li>[[Japanese functions]]</li>
<li>[[Japanese functions]]</li>
<li>[[Sir2000 Field Migration Facility]]</li>
<li>[[Sir2000 Field Migration Facility]]</li>
</ul>
</ul>
<p class="caption">Products authorizing $Center
<p class="caption">Products authorizing $Center
</p>
</p>


[[Category:$Functions|$Center]]
[[Category:$Functions|$Center]]

Revision as of 19:48, 31 January 2011

<section begin="desc" />Center string<section end="desc" />

Most Sirius $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for the $Center function is the Center (String function or alias Centre (String function).

This function builds a string of an indicated length containing a centered input string.

The $Center function accepts three arguments and returns a string result that contains the first argument string, centered in an area with leading and trailing pad characters.

The first argument is the string to be centered.

The second argument is the length of the output string. If this argument is negative or greater than 255, the request is canceled. Omitting this argument invokes a special usage of $CENTER, as described at the end of this section.

The third argument is a pad character to be used for centering the result string. This is an optional argument and defaults to blank.

Syntax

<section begin="syntax" /> %STRING = $Center(string, length, pad) <section end="syntax" />

$Center Function

%STRING is a string containing the first argument string.

For example

%JUNK = $Center('PAGE TITLE', 12)

sets %JUNK to ' PAGE TITLE ' and

%JUNK = $Center('PAGE', 5)

sets %JUNK to 'PAGE ' and

%JUNK = $Center('PAGE', 1)

sets %JUNK to 'A' and

%JUNK = $Center('PAGE', 2)

sets %JUNK to 'AG' and

%JUNK = $Center('PAGE TITLE', 17, '-')

sets %JUNK to '---PAGE TITLE----'.

There is also an alternate usage for $Center, if the second argument (length is omitted. In this case, the third argument is ignored, and the first argument must be of the form:

lenpstring

Where:

len The first three bytes of the argument must be a decimal number which is at least as long as the string (trailing portion of the argument. This number is used as the result length, containing the centered string.
p The fourth byte of the argument is the pad character for the output. The pad characters just before and just after the centered string in the output are each replaced by a blank.
string The string to be centered; this can be from 1 to 251 bytes in length.

If this form of $Center is used and any of the above restrictions are not met, the value returned by $Center is a single digit '1'. Note that this error return value is indistinguishable only to the valid invocation $Center('001p1'), where p is any pad character.

Products authorizing $Center