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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:25:43+00:00 2026-06-12T13:25:43+00:00

I’m having a problem when I use these 2 FOR to initialize a two

  • 0

I’m having a problem when I use these 2 FOR to initialize a two dimensional vector/array:
I have these types defined:

type
  Range9         = 0..8;
  Digit         = '0'..'9';
  Board    = array [Range9,Range9] of Digit;

and then the part of the code where there are problems with the FOR’s is the following:

var
  i : Range9;
  j : Range9;
  table : Board;
BEGIN

for i:=0 to 8 do begin
  for j:=0 to 8 do begin
    table[i,j] := '0'
  end
end;

END.

Now the problem is that, when I debug this portion of code, for some reason, my i variable is modified when it’s not supposed to.

For example, I have a watch on i and j and if I put a breakpoint in the line table[i,j] := 0
I see with the watches these values:

i    j
0    0
256  1
512  2
768  3
1024 4
1280 5
1536 6
1792 7
2048 8
2049 8
1    0
257  1
513  2
769  3

and so on…

So, when the program enters in the second for (the one that increases the j) my i increases in intervals of 256… I really don’t know why is this happening.

And another thing I discovered is that, the problem solves if I change the TYPE of the i variable.
If in the VAR section I put i : integer instead of i : Range9, i doesn’t get modified when isn’t supposed to.

I would really appreciate if someone explains me why is happening this.

  • 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-12T13:25:45+00:00Added an answer on June 12, 2026 at 1:25 pm

    I’ve found the answer to my own question… well, I didn’t exactly found the answer, I’ve asked this same question in the forum board of the programming course I’m attending and one of the professors gave me this link:

    (it’s in spanish btw)
    http://www.fing.edu.uy/inco/cursos/prog1/pm/field.php/FAQ/Laboratorio#toc17

    A quick translation:

    This happens with variables defined as subranges. The reason isn’t sure; but without doubt is an implementation error of the debugger. There is a ‘trick’ that can work to solve this (although not always), to be able to see the correct values on the debugger:

    Suppose that you have the following variable in your program:

    var anything: 1 .. 10;
    

    Add in your program a integer variable which won’t be used in any part of the program:

    var anything: 1..10;
        aux: integer;  { only for the debugger }
    

    Then when you define the debugger watch, instead of adding the anything variable, you should add the following expression:

    aux:= anything
    

    The aux variable can be used to view different variables, so you only need to declare one aux variable.

    In some cases, the previous may not work. Another solution is to change the type of all the variables defined with subranges to integer, char, string, etc (depending the case) only for debug and the change it back again.

    end of the translation.

    Hope this will be useful for someone else facing the same error.
    BTW, this happens with the debugger of free pascal IDE 2.2.2 , maybe in another IDE/compiler/debugger of pascal it doesn’t happen.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have an array which has BIG numbers and small numbers in it. I
I've tracked down a weird MySQL problem to the two different ways I was
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
this is what i have right now Drawing an RSS feed into the php,
I have a small JavaScript validation script that validates inputs based on Regex. I
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.