Use this function to center text within a specified length and return the result.
Note | To justify a display item, such as a field, on a fixed point use the JustField function. The JCenter function is for padding a text string so it will appear centered within a given string length. |
Parameter |
Description |
String |
Enter a valid string. The default is the value of the current field. |
Length |
Specify the desired length of output. The default is the length of the input string. |
The system justifies the text characters of the string parameter within the specified length and returns the new string.
If the length specified in the Length parameter is longer than the string, the result will be increased to the given length before the system centers the string. If the length specified is less than the string, the length of the string is used.
For example, if the variable field has a length of 30, the DAL script says Return(JCenter (,10)), and you enter ABC in the variable field, the system will center ABC using a length of 10 instead of 30.
Here are some examples:
(Assume the current field contains the text Name and can be up to 20 characters.)
Function |
Result |
Explanation |
JCenter ( , Size ( ) ) |
" Name " |
First the Size function determines that the maximum length of the field is 20. Then the JCenter function defaults to the current field and centers the text name within the given size of 20. |
JCenter ("Complete blanks.", 5) |
Complete blanks. |
Ignores the specified length (5) because it is less than the given string. |
JCenter ("Complete blanks.", 25) |
" Complete blank. " |
Increases the size of the input string to 25 and centers the text. The variable field length is not affected, so the text appears to be off center. |
© Copyright 2017, Oracle and/or its affiliates. All rights reserved. Legal Notices