copy subset of character array to another character array

Hi,
I am trying to copy part of one character array to a shorter character array. I found this solution so am trying to do it this way:
ShorterArray := Copy(LongArray, 0, Number);
I sized the shorter array to Number. Long array is the longer source array. 0 is the first element of the source array to copy. Number is the number of elements to copy. During complie I get the error saying "incompatible types 'Dynamic Array' and 'String'".
Why isn't this working ? Does it not work with a character array ? Or can't I do it with a dynamic array ? I assume I could loop through the elements copying them one at a time, but wanted the most elegant solution. Is there a better way ? Can I size the destination array at the same time ?
ChLaAsked:
Who is Participating?
 
Ephraim WangoyaCommented:

Thats because your ShorerArray is an array while the copy function is returning a string.
You can not directly assign a string to an array
0
 
Ephraim WangoyaCommented:
If you want an elegant way, you could do this

Move(LongArray, ShortArray, SizeOf(Char) * Number);
0
 
ChLaAuthor Commented:
Thank You
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.