xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

CStr()

Converts a value to a character string.

Syntax

CStr( <xValue> ) --> cString

Arguments

<xValue>
This is a value of any data type.

Return

The function returns a character string holding the converted value.

Description

Function CStr() accepts a value of any data type and returns a character string holding information about the value. This character string can be output to the screen or printer, and is of informational use only when <xValue> is a complex data type (Array, Code block, Hash or Object).

Info

See also:CStrToVal(), DtoS(), HB_ValToStr(), Str(), Transform(), Valtype(), ValToPrg(), ValToPrgExp()
Category: Conversion functions , Debug functions , xHarbour extensions
Source:rtl\cstr.prg
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example demonstrates return values of function CStr()
// for all data types available in xHarbour.

   PROCEDURE Main
      LOCAL aArray   := { 1, 2, 3 }
      LOCAL bBlock   := {|| Time() }
      LOCAL cString  := "xHarbour"
      LOCAL dDate    := Date()
      LOCAL hHash    := { "A" => 1, "B" => 2 }
      LOCAL lLogic   := .T.
      LOCAL nNumber  := 1.2345
      LOCAL obj      := Get():new()
      LOCAL pPointer := ( @Main() )
      LOCAL undef    := NIL

      ? CStr( aArray   )    // result: { Array of 3 Items }
      ? CStr( bBlock   )    // result: {|| Block }
      ? CStr( cString  )    // result: xHarbour
      ? CStr( dDate    )    // result: 20061006
      ? CStr( hHash    )    // result: { Hash of 2 Items }
      ? CStr( lLogic   )    // result: .T.
      ? CStr( nNumber  )    // result:          1.2345
      ? CStr( obj      )    // result: { GET Object }
      ? CStr( pPointer )    // result: 4CB000
      ? CStr( undef    )    // result: NIL
   RETURN

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe