Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 593427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:50:41+00:00 2026-05-13T15:50:41+00:00

I have an array declared as: const A: array[0..3] of ShortString = ( ‘Customer’,

  • 0

I have an array declared as:

const A: array[0..3] of ShortString = (
  'Customer',
  'Supplier',
  'Stock',
  'GL'
);

var B: array of ShortString;

I would like to clone the string array A to another array B. Using Move or Copy function doesn’t work. Is there a fast and easy way to clone the array without using for loop?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T15:50:41+00:00Added an answer on May 13, 2026 at 3:50 pm

    The problem you face is that your constant A and your variable B are actually of different types. This can be demonstrated most easily by showing how you would declare a const and a var of the same type in a fashion equivalent to what you show in your question:

    type
      TSA = array[0..3] of ShortString;
    
    const
      A: TSA = (
      'Customer',
      'Supplier',
      'Stock',
      'GL');
    
    var B: TSA;
    

    With these declarations you could then simply write:

    B := A;
    

    But when A is a dimensioned array and B is a dynamic array, this isn’t possible and your only option is to SetLength(B) as required and copy the elements one-by-one.

    Although the const and the var types may look like they are the same – or compatible types – they are not, and this then is no different from trying to assign an Integer constant to a String variable… even though you know the simple conversion required to achieve it, the compiler cannot presume to guess that you intended this, so you have to be explicit and provide the conversion code yourself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have declared an array in the form: var refs = { 'EE810': Presence
I have a variable declared like this in a class: Entity *array[BOARD_SIZE][BOARD_SIZE]; I need
for each letter in the alphabet i have an int-array declared like this: int
I have the following array declared inside a header file. static const float elementsArray[300]
I have a C++ array declared as mentioned below: CString carray[] = { A,
I have a variable length array of strings declared in javascript that contains Dungeons
I have the following as two ways to declare a two dimensional String array.
I have array like this: $path = array ( [0] => site\projects\terrace_and_balcony\mexico.jpg [1] =>
I have declared a DLL import in my C# program that looks like this:
I have a program which declares an array of strings like this: char *colors[4]

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.