[fpc-pascal] Strange!!
Peter Rosendahl
peteros at algonet.se
Mon Jan 9 17:03:20 CET 2006
Hello,
I'm a beinner at Pascal, (Ok was 10years since I did someting serious) and have noticed a strange thing when compiling with 2.0.2 version.
This is the part where I read a TEXT file with numbers.
Procedure Openfile; { Module 1 }
VAR
Infile : Text;
Filename : String[12];
num : String[2]; // <----------------- Notice string of lenght 2
temp : String[1];
tempnum,slask: integer;
BEGIN
Write('Input Name Of file: ');
Readln(Filename);
Assign(Infile,Filename);
Reset(Infile);
Count := 0;
While Not EOF(Infile) DO
BEGIN
Inc(count);
IF Count > MaxRow THEN Error;
FOR i := 1 TO 6 DO BEGIN
Read(Infile,Num);write(Num);Readln;
{* <<--- this is suppose to read One number at a time, width 6 *)
Val(Num,tempnum,slask);
Wheel[count,i] := tempnum;
Read(Infile,temp);
END;
Readln(Infile);
END;
Close(Infile);
END;
My original file starts with
01 04 22 26 36 49
01 04 22 29 39 45
01 04 22 31 33 38
01 04 27 29 35 38
01 05 07 30 31 47
Compiled with 1.0.6 on AMD 900Mhz the output is
01
04
22
26
36
49
01
04
22
29
39
45
01
04
22
31
33
Compiled with 2.0.2 on 2600+ AMD (Both WinXP Pro) the output is
01 04 22 26 39 49
With the EXACT same code compiled with different versions of Freepascal, one reads the string[2] as 2 letter and the other version reads the entire line as string[2].
please can anyone explain this to and possible find a solution
Regards
Peter Rosendahl
More information about the fpc-pascal
mailing list