Toby Ewing wrote:
Alternatively, you could perhaps do without a schema:
var Buffy: array [0 .. wid - 1] of ByteCard;
Can't do that: the program has to adjust to different sized images. Wid is determined by a combination of input file and user input, so there's no way to know it at compile time.
As I tried to explain, it doesn't have to be known at compile time. Of course, it has to be known at runtime when the declaration is made. If you need it in a routine which determines the size during its execution, you could either put the declaration in the statement part (non-standard) or move it to a subroutine.
GPC allows such non-constant sized declarations according to EP.
And why isn't the program complaining?
Because GPC doesn't (yet) implement runtime range-checking. One of the next versions will.
I thought that I'd get a memory violation, or GPF, or something like that.
This depends on what's there in memory. In this case, it's the discriminant, so you will clobber it (which might to subsequent problems later when you do some things with the schema).
In other cases, there may be other variables which get clobbered. You can't expect to always get memory violations. Tools like efence will help somewhat (i.e., produce more segfaults on invalid accesses), but not 100% (see the doc). That's why we need compiler generated runtime range-checking at all.
Frank