[Gambas-user] Opposite of Split
Eilert
eilert-sprachen at ...221...
Thu Jun 16 17:51:10 CEST 2005
Hi Laurent,
just look at the mail from Rob, he's pointed me to the function I was
looking for. There is really a ready-made thing, so we won't need to
program one for ourselves :-)
Rolf
Laurent Carlier schrieb:
> Le Jeudi 16 Juin 2005 16:29, Eilert a écrit :
>
>>Hi,
>>
>>is there an opposite of the Split function? Something like "join" or so
>>that can put together the contents of an array into a string, separated
>>by any separator?
>>
>>Rolf
>
>
> Here it's better :) :
>
> PUBLIC SUB Main()
>
> DIM myarray AS NEW Variant[]
>
> myarray.Push(12)
> myarray.Push("a string")
> myarray.Push(Now)
>
> PRINT join(myarray, ",")
>
> END
>
> PUBLIC FUNCTION join(tArray AS Variant[], OPTIONAL separator AS String = " ")
> AS String
>
> DIM myvar AS Variant
> DIM mystr AS String
>
> FOR EACH myvar IN tArray
> mystr = mystr & CStr(myvar) & separator
> NEXT
>
> RETURN Left$(mystr, -1)
>
> END
>
> => 12,a string,06/16/2005 17:18:14
>
More information about the User
mailing list