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 9274141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:17:07+00:00 2026-06-18T16:17:07+00:00

i need to declare an array with user-defined dimension. This array is inside a

  • 0

i need to declare an array with user-defined dimension. This array is inside a pretty big program and change to a list can be pretty a problem.

Now my array is declared like this:

Buffer: array[0..myCostant * 2] of Byte;

and myCostant is, like it says, an already defined constant.
Now i need to use a variable, getting something like this:

Buffer: array[0..myVar * 2] of Byte;

but i can’t use variables inside array definition.

How i can solve this without changing my array in something else?
This variable is upper-bounded so can i declare array with this max size and reduce it with another instruction?

  • 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-06-18T16:17:09+00:00Added an answer on June 18, 2026 at 4:17 pm

    You should use dynamic arrays:

    var
      Buffer: array of Byte;
    
    begin
      SetLength(Buffer, myVar*2 + 1);
    

    Alternatively, you can use a static array of the known upper-bound length and record the current ‘meaningful’ length of the array in a variable, say CurrentLength.

    Then you can replace, for instance,

    for i := 0 to Length(Buffer) - 1 do
      SomethingWith(Buffer[i]);
    

    by

    for i := 0 to CurrentLength - 1 do
      SomethingWith(Buffer[i]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to declare 3d array variable but can't. int[][][] ary = new int[5][2][];
I want to declare static(or not static) variable inside Enum. I need this because
Very similar to this post How can I declare template array as a parameter
When I need to declare a new array I use this notation var arr
In my application, i need to declare an Array based on the value stored
I have a variable declared like this in a class: Entity *array[BOARD_SIZE][BOARD_SIZE]; I need
I can't understand why my javascript isn't working... Do i need to declare a
I need to declare an array globally, because I want all methods to be
I'm working on a embedded application where I need to declare an array of
I am having an issue with this program. I need it to ask for

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.