$Center: Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (1 revision)
(Automatically generated page update)
 
(22 intermediate revisions by 5 users not shown)
Line 2: Line 2:
<span class="pageSubtitle">Center string</span>
<span class="pageSubtitle">Center string</span>


<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>
<p class="warn"><b>Note: </b>Many $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for the $Center function is the [[Center (String function)|Center]] function or alias [[Centre (String function)|Centre]].</p>


This function builds a string of an indicated length containing a centered input string.  
The <var>$Center</var> function accepts three arguments and returns a string result that contains the first argument string, an indicated length, centered in an area with leading and trailing pad characters.  


The <var>$Center</var> 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.  
==Syntax==
<p class="syntax"><span class="term">%string</span> = <span class="literal">$Center</span>(<span class="term">string</span>, <span class="term">length</span>, [<span class="term">pad</span>])
</p>
 
<p>%string is a string containing the first argument string.</p>


The first argument is the string to be centered.  
The first argument is the string to be centered.  
Line 13: Line 17:


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.
==Syntax==
 
<p class="syntax"><section begin="syntax" />%STRING = $Center(string, length, pad)
==Examples==
<section end="syntax" /></p>
<p>
</p>
<p>%STRING is a string containing the first argument string.</p>
For example
<p class="code"> %JUNK = $Center('PAGE TITLE', 12)
<p class="code"> %JUNK = $Center('PAGE TITLE', 12)
</p>
</p>
sets %JUNK to <tt>' PAGE TITLE '</tt> and
sets %JUNK to <code>' PAGE TITLE '</code> and
<p class="code"> %JUNK = $Center('PAGE', 5)
<p class="code"> %JUNK = $Center('PAGE', 5)
</p>
</p>
sets %JUNK to <tt>'PAGE '</tt> and
sets %JUNK to <code>'PAGE '</code> and
<p class="code"> %JUNK = $Center('PAGE', 1)
<p class="code"> %JUNK = $Center('PAGE', 1)
</p>
</p>
sets %JUNK to <tt>'A'</tt> and
sets %JUNK to <code>'A'</code> and
<p class="code"> %JUNK = $Center('PAGE', 2)
<p class="code"> %JUNK = $Center('PAGE', 2)
</p>
</p>
sets %JUNK to <tt>'AG'</tt> and
sets %JUNK to <code>'AG'</code> and
<p class="code"> %JUNK = $Center('PAGE TITLE', 17, '-')
<p class="code"> %JUNK = $Center('PAGE TITLE', 17, '-')
</p>
</p>
sets %JUNK to <tt>'---PAGE TITLE----'</tt>.  
sets %JUNK to <code>'---PAGE TITLE----'</code>.  


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:
==Alternative form==
There is also an alternate usage for <var>$Center</var>, if the second argument (<var class="term">length</var> 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="syntax"><span class="term">lenpstring</span>
</p>
</p>


Line 57: Line 57:
==Products authorizing {{PAGENAMEE}}==  
==Products authorizing {{PAGENAMEE}}==  
<ul class="smallAndTightList">
<ul class="smallAndTightList">
<li>[[Sirius functions]]</li>
<li>[[List of $functions|Sirius functions]]</li>
<li>[[Fast/Unload User Language Interface]]</li>
<li>[[Fast/Unload User Language Interface]]</li>
<li>[[Janus Open Client]]</li>
<li>[[Media:JoclrNew.pdf|Janus Open Client]]</li>
<li>[[Janus Open Server]]</li>
<li>[[Media:JosrvrNew.pdf|Janus Open Server]]</li>
<li>[[Janus Sockets]]</li>
<li>[[Janus Sockets]]</li>
<li>[[Janus Web Server]]</li>
<li>[[Janus Web Server]]</li>
<li>[[Japanese functions]]</li>
<li>Japanese functions</li>
<li>[[Sir2000 Field Migration Facility]]</li>
<li>[[Media:SirfieldNew.pdf|Sir2000 Field Migration Facility]]</li>
</ul>
</ul>
<p>
</p>


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

Latest revision as of 22:51, 20 September 2018

Center string

Note: Many $functions have been deprecated in favor of Object Oriented methods. The OO equivalent for the $Center function is the Center function or alias Centre.

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

Syntax

%string = $Center(string, length, [pad])

%string is a string containing the first argument string.

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.

Examples

%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----'.

Alternative form

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