const array non-working program code

General discussion on mikroPascal PRO for AVR.
Post Reply
Author
Message
wasq
Posts: 5
Joined: 07 Jun 2018 17:19
Location: Россия, г. Самара

const array non-working program code

#1 Post by wasq » 07 Jun 2018 17:41

IDE MikroPascal PRO for AVR version 7.0.1
Atmega328P
The program does not work correctly if the index is variable. That's right, if the index is constant.

program yy;
Type ImPP = string [5];
Var
i:byte;
st:ImPP;
const Im: array [1..5] Of ImPP = ('SSSSS','WWWWW','RRRRR','FFFFF','HHHHH');
begin
{ This code does not work. The variable 'st' takes an invalid value }
i:=1;
st:= Im;
i:=i+1;
st:= Im;
i:=i+1;
st:= Im;
{ This code works. The variable takes the correct value }
st:= Im[1];
st:= Im[2];
st:= Im[3];
st:= Im[4];
st:= Im[5];

end.

I ask you to tell me what to do.

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: const array non-working program code

#2 Post by filip » 08 Jun 2018 13:56

Hi,

I apologize for the inconvenience caused by this issue, I will report this to our developers.

In the meantime, I will try to find a workaround for this.

Regards,
Filip.

wasq
Posts: 5
Joined: 07 Jun 2018 17:19
Location: Россия, г. Самара

Re: const array non-working program code

#3 Post by wasq » 08 Jun 2018 17:53

Hi
There are many simple solutions. I will show one of them.
I hope for a correction
Thank you/

program yy;
Type ImPP = string [5];
Var
i:byte;
st:ImPP;
const Im: array [1..5] Of ImPP = ('SSSSS','WWWWW','RRRRR','FFFFF','HHHHH');

Function cs(vx:byte):ImPP;
Var w:byte;
Begin
cs:='';
For w:=0 to 5 Do cs[w]:=Im[vx][w];
End;

begin
i:=1;
st:=cs(i);
i:=2;
st:=cs(i);
end.

Post Reply

Return to “mikroPascal PRO for AVR General”