[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


copy subset of character array to another character array

Posted on 2011-10-17
Medium Priority
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
  • 2
LVL 32

Accepted Solution

Ephraim Wangoya earned 2000 total points
ID: 36983705

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

by:Ephraim Wangoya
ID: 36983722
If you want an elegant way, you could do this

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

Author Comment

ID: 36989349
Thank You

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

834 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