thx
- joris
> Is there a function that can convert a SmallInt to an Integer and/or
> back? Something similar like StrToInt?
No need:
var
Sml: SmallInt;
Int: Integer;
begin
Sml := 17;
Int := Sml;
Int := 1234;
Sml := Int;
--
Rudy Velthuis (TeamB)
"Rudy Velthuis (TeamB)" wrote:
nope, not working, this is my code:
Type
Graster = array of array of Integer;
Procedure TGDataForm.GetGData(var Z:GRaster;var Formcaption:string);
var
i,j : integer;
fileIMG : file of smallint;
begin
...
for i:= 1 to nrow do
for j:= 1 to ncol do
read(fileIMG, Z[i,j]); //-> compile error: incompatible types
'smallint' and 'integer'
Any ideas?
thx
- joris
Add a temporary smallint variable and use that to assign the value. Kinda
like this:
var
i, j: Integer;
dummy: SmallInt;
fileIMG: file of SmallInt;
begin
...
for i := 1 to nrow
do for j := 1 to ncol do
begin
read(fileIMG, dummy);
z[i,j] := dummy;
end;
...
HTH,
sm
Hi,
this is a "kludge" that works, but now : why does the direct aassignment of a smallint to an integer
not work. curious...
--
Pierre Meyer
Laboratoire de Physique des Solides
Bt. 510, Universite de Paris Sud
F 91405 ORSAY, FRANCE
T : (33)-(0)1 69 15 60 62
Fx : (33)-(0)1 69 15 60 86
e-mail : me...@lps.u-psud.fr
homepage : http://www.lps.u-psud.fr/
procedure Read(var f: file of T; var p1, p2, p3...: T);
Since SmallInt and Integer have different byte sizes, the compiler can't
just substitute one for the other and an additional assignment is required.
That's how var parameters work.
HTH,
sm
> for i:= 1 to nrow do
> for j:= 1 to ncol do
> read(fileIMG, Z[i,j]); //-> compile error: incompatible types
> 'smallint' and 'integer'
Of course, this is quite different. You didn't say you wanted to read
from a file. If you'd read the SmallInts as SmallInts, and then stored
them in the array of Integer, you would succeed:
var
sml: SmallInt;
for i:= 1 to nrow do
for j:= 1 to ncol do
begin
read(fileIMG, sml);
Z[i,j] := sml;
end;
--
Rudy Velthuis (TeamB)