View Full Version : Array discrepancy between PC and PPC
PointOfLight
03-30-2007, 03:29 PM
If I declare the following:
global(arr$);
Dim(arr$, 11);
On the PC I can do:
for(i$, 0, 11)
//Do something with arr$[i$];
end;
However, if I run the same code on the PPC, I get an error saying that index 11 is out of range for the array. In order to access index 11 on the PPC, I have to do:
Dim(arr$, 12);
kornalius
03-30-2007, 03:39 PM
When you DIM 11 elements, it will range from 0 to 10 only. Not 0 to 11. 0 is one element.
PointOfLight
03-30-2007, 03:53 PM
Then the PC side is not working right, because
Dim(var$, 11);
gives me 12 elements on the PC, indexed 0 to 11. The project I just sent you will illustrate that. If you reduce the number by 1 in each of the Dim statements at the beginning of LoadResources, the program will still work fine on the PC, but puke on the PPC.
kornalius
03-30-2007, 04:02 PM
I have just tested this on both platforms and see no problems. In RangeCheck mode (default in the PIDE) it gives me an error on element 11 on the PC and PPC. Make sure RangeCheck mode is active in the PIDE compiler options.
The RangeCheck mode is only active using the PIDE. No range checking is done in normal runs to keep execution speed optimal. From the Main.ppl or directly running a .ppl, .ppc or .exe, it won't do range checking.
PointOfLight
03-30-2007, 06:01 PM
If I go to Run | Compiler Options in the PIDE, I do not see a Range Check option.
kornalius
03-30-2007, 07:03 PM
Sorry, Run will do Range Checking automatically. If you don't want to you can Run Dedicated instead.
quangdx
03-30-2007, 07:27 PM
can you make an EXE with range checking turned off?
would be useful to get a bit more speed, with a program that has lots of arrays and you know will not go out of range.
PointOfLight
03-30-2007, 08:23 PM
Based on what Alain said, Range Checking only applies while in the PIDE, so an executable would be exempt from Range Checking.
kornalius
03-30-2007, 08:35 PM
Executables don't have range checking.
Hi, the original PointofLight's question remains here, why is running e.g. this example normaly ? (on my PC) :
global(arr$);
global(i$);
Dim(arr$, 1);
arr$[0] = "a";
arr$[1] = "b";
for(i$, 0, 1)
ShowMessage(arr$[i$]);
end;
Jerry
------------------------
PPLG (PPL is Great)
kornalius
03-31-2007, 12:12 AM
Is this running from the PIDE direclty?
PointOfLight
03-31-2007, 01:33 AM
For me, yes. If I did:
Dim(var$, 11);
I could do this:
for(i$, 0, 11)
var$[i$] = x;
end;
Without getting an error when var$[11] was accessed, even through the PIDE.
Yes, my example is running "errorless" - directly from the PIDE - but only on a PC, on a PPC it writes a runtime error "out of range"
Jerry
-------------------------
PPLG (PPL is Great)
matteo.m
03-31-2007, 03:19 PM
is the same that i tried to explain in this post
http://www.arianesoft.ca/e107_plugins/forum/forum_viewtopic.php?3315
at the end i raised of 1 element my arrays :)
Yes, it looks like a trailing error...
Jerry
-------------------------
PPLG (PPL is Great)
kornalius
03-31-2007, 08:26 PM
Sounds like the PC version is probably assigning more bytes (read 4 bytes alignment). I don't know why the PPC gives an error when on the PC it doesn't. I will look it up next week. Thank you for reporting this.
kornalius
04-02-2007, 04:50 PM
I clearly get a range check error on the PC. I will look into the range check error in depth now.
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.