FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Array <> String
Posts: 437
Joined: Fri Oct 07, 2005 12:56 PM
Array <> String
Posted: Sun Jan 29, 2012 05:47 PM

Hi,

Exist or not functions to convert array to str and str to array ? Can't find at this moment ... If not exist , maybe you can share with working solution ?

Thanks !

Rimantas U.
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Array <> String
Posted: Mon Jan 30, 2012 12:08 AM
Rimantas,

This may help you:

Code (fw): Select all Collapse
#include "FiveWin.ch"

extern HBCharacter

function Main()

    local c := "Hello"

   ASSOCIATE CLASS String WITH TYPE Character

    MsgInfo( c[ 1 ] )
    MsgInfo( c )

return nil

CLASS String

   METHOD GetChar( nIndex ) OPERATOR "[]"

   METHOD ClassName() INLINE "CHARACTER"

ENDCLASS

METHOD GetChar( nIndex ) CLASS String

return SubStr( Self, nIndex, 1 )
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Re: Array <> String
Posted: Mon Jan 30, 2012 08:05 AM
Rimantas,

simple function to save an array into a string, the fields separated with ";"

Code (fw): Select all Collapse
FUNCTION SaveArray2String  (aArray)

  LOCAL i
  LOCAL c := ""

  FOR i := 1 TO Len (aArray)
     c += aArray[i]+";"
  NEXT
  c := Left (c, Len(c)-1) // remove the last ;

RETURN (c)
kind regards

Stefan
Posts: 437
Joined: Fri Oct 07, 2005 12:56 PM
Re: Array <> String
Posted: Mon Jan 30, 2012 12:36 PM
StefanHaupt wrote:Rimantas,
simple function to save an array into a string, the fields separated with ";"


Hi Stefan ,
Thanks , something similar I did at this moment . Simply I was thinking that alreday exist solution .

With best regards !
Rimantas U.
Posts: 437
Joined: Fri Oct 07, 2005 12:56 PM
Re: Array <> String
Posted: Mon Jan 30, 2012 12:37 PM
Antonio Linares wrote:Rimantas,

This may help you:
Code (fw): Select all Collapse
#include "FiveWin.ch"
extern HBCharacter


Interesting ... Thanks Antonio !

With best regards !
Rimantas U.

Continue the discussion