Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- The Guide To Clipper - <b>pad() pad character string with trailing spaces examplep.prg</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Pad()    Pad character string with trailing spaces        Examplep.prg


Syntax:        Pad(<expC>, <expN>)

Arguments:     <expC> is the character string to pad with space
               characters.

               <expN> is the length of the character string to
               return.

Returns:       A character string.

               Pad() returns <expC> padded with up to <expN> blanks.  If
               the length of <expC> exceeds <expN>, Pad() returns
               SUBSTR(<expC>, 1, <expN>).

Description:   Pad() is used primarily to display variable length
               strings within a fixed length area.  It can be used, for
               instance, to assure alignment with consecutive ??
               commands.  Another use is to write to a fixed-width
               screen area assuring that previous text is completely
               overwritten.

Library:       EXTEND.LIB


----------------------------------- Example --------------------------------

   This example uses Pad() to format a record number display on a status
   line to fill the allocated space.

   IF EOF()
        @ 23, 45 Pad("EOF/" + LTRIM(STR(LASTREC)), 20)

   ELSEIF BOF()
        @ 23, 45 Pad("BOF/" + LTRIM(STR(LASTREC)), 20)

   ELSE
        @ 23, 45 SAY Pad("Record " + LTRIM(STR(RECNO()) + "/" + ;
                        LTRIM(STR(LASTREC)), 20)
   ENDIF


--------------------------------- Source code ------------------------------

   FUNCTION Pad

   PARAMETERS string, length
   RETURN SUBSTR(string + SPACE(length), 1, length)



See Also: ALLTRIM() LTRIM() TRIM()

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