Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - padc() center-pad a string with fill character http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 padc()              Center-pad a string with fill character
------------------------------------------------------------------------------
 Declaration
   string.hdr

 Syntax
   func char padc extern
   param const char cString, ;
         value uint uLength, ;
         value byte bChar

 Arguments
   cString is a character string.

   uLength is the length of the output string.

   bChar is the pad character.

 Return
   A string derived from the input string, with leading and trailing pad
   characters added to center the string.

 Description
   This function returns a string with a length of uLength, made up of
   cString included between as many bChar characters that are needed to fill
   up the string to a length of uLength. The resulting string is centered
   within uLength.

   If the length of cString is larger than uLength then the string
   is trimmed to uLength.

 Example
   #define EXAMPLE_STRING
   #include example.hdr

   proc Test_padc
   ? padc( "hello  ",  3, '*' )  // Output: hel
   ? padc( "hello  ",  5, '*' )  // Output: hello
   ? padc( "hello  ", 10, '*' )  // Output: *hello **
   ? padc( "hello  ", 11, '*' )  // Output: **hello  **
   endproc

   proc main
   Test_padc()
   endproc

See Also: padl() padr()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson