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 - center() center a string within a specified width http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 center()            Center a string within a specified width
------------------------------------------------------------------------------
 Declaration
   string.hdr

 Syntax
   func char center extern
   param const char cString, ;
         value uint uLength

 Arguments
   cString is a character string.

   uLength is the output string length.

 Return
   A string corresponding to the input string, with leading and trailing
   spaces added.

 Description
   The center() function returns a character string of length uLength
   with leading and trailing spaces, so that cString is centered.

 Example
   #define EXAMPLE_STRING
   #include example.hdr

   vardef
      char(40) signon[4] := "G.L. Module", "by", ;
                            "Peak Software", ;
                            "(c) 1998, Peak, Inc"
      int      i
   enddef
   
   proc Test_center
   // Print centered page identifier for a report.
   ? center( dtoc( today() ) + " Report: Sales", 80 )
   // Print a centered sign-on message.
   for i := 0 to 3
      ? center( signon[i], 80 )
   next
   endproc

   proc main
   Test_center()
   endproc

See Also: ladjust() padc() radjust() space() stuff()

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