Hi, all
Having fun with Schema; thanks, Frank!
I mentioned yesterday that I was getting a compiler warning when I used Cards
rather than Integers for Schema, and Frank wanted to know more. Below is a
(remarkably familiar) test program.
When I compile the program, I get the warning:
Warning: comparison is always "True" due to limited range of data type
for the three "i" loops. Oddly enough, the "j" and "k" loops get no warning,
though in other similar programs I've had warnings for each of nested loops.
The medCard variables do not produce warnings when changed to shortCard, nor
does the shortCard variable produce an error if it is changed to medCard. As
you might guess, byteCard produces the same warning as shortCard.
regards,
Toby
-----------------------------------
program testmem;
type
Fieldary(sY, sZ : medCard) = array[1..sY,1..sZ] of Real;
FPary(sX : medCard) = array[0..sX] of ^Fieldary;
var
Field : ^FPary;
i, j, k : byteCard;
nx, ny, nz : medCard;
begin
write('Enter sizes in x, y, and z: ');
readln(nx, ny, nz);
New(Field, nx);
for i := 0 to nx do New(Field^[i], ny, nz);
writeln('Memory allocated OK');
for i := 0 to nx do
for j := 1 to nx do
for k := 1 to nx do Field^[i]^[j,k] := 1.0 * i * j * k;
writeln('Freeing memory...');
for i := 0 to nx do Dispose(Field^[i]);
Dispose(Field);
end.