Strange!!

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Strange!!

Peter Rosendahl
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

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Strange!!

Jonas Maebe-2

On 9 jan 2006, at 17:03, Peter Rosendahl wrote:

> 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

It is a bug in version 2.0.2 which has been fixed in the mean time.


Jonas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Strange!!

Peter Rosendahl

Thank you for your quick answer, how do I get the new version? Is the 2.0.2 available at this point the FIXED version, or do I have to recompile from some unstable source ?

/Peter



JM> On 9 jan 2006, at 17:03, Peter Rosendahl wrote:

>> 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

JM> It is a bug in version 2.0.2 which has been fixed in the mean time.


JM> Jonas

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Strange!!

Jonas Maebe-2

On 9 jan 2006, at 17:18, Peter Rosendahl wrote:

> Thank you for your quick answer, how do I get the new version? Is  
> the 2.0.2 available at this point the FIXED version,

2.0.2 is 2.0.2. It will not change.

> or do I have to recompile from some unstable source ?

If you are using Windows, you can download a 2.0.3 snapshot from the  
fixes branch (which is pretty stable) from
   ftp://ftp.freepascal.org/pub/fpc/snapshot/v20/i386-win32/

Only the "base" snapshot seems to be up-to-date though, but it should  
work with the rest of the units from 2.0.2.


Jonas
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal