shortint bug

robert
Benutzer
Avatar
Gender: n/a
Location: Hildesheim / Deutschland
Posts: 249
Registered: 04 / 2006
Subject:

shortint bug

 · 
Posted: 25.06.2010 - 10:27  ·  #1
Hallo,
folgendes Programm benutzt shortints als Index für ein Array. Leider funktioniert das nicht mit negativen Werten. Auch wird die For-Schleife nicht durchlaufen.
Code
program bla;

{$NOSHADOW}
{ $WG}                     {global Warnings off}

Device = mega2560, VCC=5;
{ $BOOTRST $1F000}         {Reset Jump to $1F000}

Import SysTick, SerPort;

From System Import ;


Define
  ProcClock      = 16000000;       {Hertz}
  SysTick        = 10;             {msec}
  StackSize      = $0100, iData;
  FrameSize      = $0100, iData;
  SerPort        = 57600, Stop2;    {Baud, StopBits|Parity}
  RxBuffer       = 8, iData;
  TxBuffer       = 8, iData;

Implementation

{$IDATA}

const
  MinVal : shortint = -2;
  MaxVal : shortint =  2;
  
  arr    : array[MinVal..MaxVal] of integer = (-20, -10, 0, 10, 20);

var
  i : shortint;
  
begin
  EnableInts;
  WriteLn(SerOut, 'Los!!!');
  for i := MinVal to MaxVal do   //Diese Schleife wird nicht durchlaufen
    WriteLn(SerOut, 'i = ' + ByteToStr(i:3) + '   arr[i] = ' + IntToStr(arr[i]:3));
  endfor;
  i := -2;                       //Liefert ein falsches Ergebnis
  WriteLn(SerOut, 'i = ' + ByteToStr(i:3) + '   arr[i] = ' + IntToStr(arr[i]:3));
  i := -1;                       //Liefert ein falsches Ergebnis
  WriteLn(SerOut, 'i = ' + ByteToStr(i:3) + '   arr[i] = ' + IntToStr(arr[i]:3));
  i := 0;
  WriteLn(SerOut, 'i = ' + ByteToStr(i:3) + '   arr[i] = ' + IntToStr(arr[i]:3));
  i := 1;
  WriteLn(SerOut, 'i = ' + ByteToStr(i:3) + '   arr[i] = ' + IntToStr(arr[i]:3));
  i := 2;
  WriteLn(SerOut, 'i = ' + ByteToStr(i:3) + '   arr[i] = ' + IntToStr(arr[i]:3));
end bla.


Robert
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: shortint bug

 · 
Posted: 26.06.2010 - 19:51  ·  #2
Hallo Robert,

Problem array mit Int8 indexes ist jetzt geändert und tut.
For loops mit Int8 als Laufzeit parameter werden noch nicht unterstützt. Bitte While oder Repeat benutzen.

rolf
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 15 · Cache Hits: 14   51   65 · Page-Gen-Time: 0.023602s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI