copy subset of character array to another character array

Posted on 2011-10-17
Last Modified: 2012-05-12
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 ?
Question by:ChLa
    LVL 32

    Accepted Solution


    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
    LVL 32

    Expert Comment

    If you want an elegant way, you could do this

    Move(LongArray, ShortArray, SizeOf(Char) * Number);

    Author Comment

    Thank You

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
    In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now