To Center a String [ Command Interpreter Access and Variables Programmer's Guide ] MPE/iX 5.0 Documentation
Command Interpreter Access and Variables Programmer's Guide
To Center a String
The CENTER command file is an example of string manipulation functions.
It centers a supplied string and displays it on $STDLIST, usually the
user's terminal screen.
A character string is entered as parameter data when the command file is
invoked. The variable CENT_SPC is defined as a string variable of 40
blank spaces. A portion of this string of blanks is inserted on the left
side of the original text string to center it. The expression determines
the number of blanks to be entered and adds them to the character string
before echoing the phrase. Note that parameters must always use explicit
dereferencing.
_________________________________________________________________
| |
| PARM STRING |
| SETVAR CENT_SPC " "|
| ECHO ![LFT(CENT_SPC,(80-LEN("!STRING"))/2)]!STRING |
| DELETEVAR CENT_SPC |
| COMMENT ** END OF CENTER ** |
_________________________________________________________________
Figure 7-1. Center Command File
The repeat function can also be used to simplify this routine.
______________________________________________________
| |
| PARM STRING |
| ECHO ![RPT(" ",(80-LEN("!STRING"))/2)]"!STRING"|
| COMMENT ** END OF CENTER ** |
______________________________________________________
Figure 7-2. Center Command File with the Repeat Function
MPE/iX 5.0 Documentation