Space()

Space()

Returns a string of blank spaces

Syntax

      Space( <nSize> ) --> cString

Arguments

<nSize> The length of the string

Returns

<cString> A string containing blank spaces

Description

This function returns a string consisting of <nSize> blank spaces. If the value of <nSize> is 0, a NULL string (“” ) will be returned.

This function is useful to declare the length of a character memory variable.

Examples

      PROCEDURE Main()
         LOCAL cBigString
         LOCAL cFirst
         LOCAL cString := Space( 20 )  // Create an character memory variable
                                       // with length 20
         ? Len( cString )      // 20
         cBigString := Space( 100000 ) // create a memory variable with 100000
                                       // blank spaces
         ? Len( cBigString )
         USE tests NEW
         cFirst := MakeEmpty( 1 )
         ? Len( cFirst )
         RETURN

      FUNCTION MakeEmpty( xField )
         LOCAL nRecord
         LOCAL xRetValue

         IF ! Empty( Alias() )
            nRecord := RecNo()
            dbGoto( 0 )
            IF ValType( xField ) == "C"
               xField := AScan( dbStruct(),  {| aFields | aFields[ 1 ] == Upper( xfield ) } )
            ELSE
               DEFAULT xField TO 0
               IF xField < 1 .OR. xField > FCount()
                  xfield := 0
               ENDIF
            ENDIF
            IF !( xfield == 0 )
               xRetvalue := FieldGet( xfield )
            ENDIF
            dbGoto( nrecord )
         ENDIF
         RETURN xRetvalue

Compliance

Clipper

Platforms

All(64K)

Files

Library is core

Seealso

PadC(), PadL(), PadR(), Replicate()

Advertisements

3 responses to “Space()

  1. Pingback: Harbour All Functions – S | Viva Clipper !

  2. Pingback: Harbour String Functions | Viva Clipper !

  3. Pingback: Harbour RG Summary | Viva Clipper !

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s