[Fixed]v1.40 Problem with StrCmp (P16 only)

Beta Testing discussion on mikroPascal PRO for PIC.
Post Reply
Author
Message
Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

[Fixed]v1.40 Problem with StrCmp (P16 only)

#1 Post by Dany » 19 Apr 2009 12:38

Fixed in bèta v1.50. :D

Hi, the code below results in "0" in variable "Shrt":

Code: Select all

var Shrt: short;
    S1, S2: string[10];
...
  S1 := '1235';
  S2 := '1236';
  Shrt := StrCmp(S1, S2);
No matter the contents of S1 and S2, the result of StrCmp is always 0.

Thanks in advance! :D

p.s. code was compiled for P16F877A
Last edited by Dany on 13 May 2009 14:45, edited 4 times in total.
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

#2 Post by Dany » 19 Apr 2009 15:08

H, I did try to write my own code for StrCmp for a 16F877A and it did also not work. :?:

Fixed in bèta v1.50.:D
The reason is that expressions like the one below are not correctly executed:

Code: Select all

var Shrt: short;
    S1, S2: string[10];
    I: word;
...
  I := 0;
  while (S1[I] > 0) and (S2[I] > 0) and (S1[I] = S2[I]) do
  begin
    Inc(I);
  end;
No matter if S1 differs from S[2] or not, the while loop is executed as long one of both chars is not zero.

Expression "S1 = S2" returns always true apparently. After some investigations it seems that "S1 < S2" and "S1 < S2" always return false.

Thanks in advance!

p.s. for P18 this type of code is executed correctly.
Last edited by Dany on 13 May 2009 14:46, edited 1 time in total.
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

User avatar
srdjan
mikroElektronika team
Posts: 1552
Joined: 28 Dec 2005 12:47
Location: Serbia

#3 Post by srdjan » 21 Apr 2009 10:43

Hi,
Dany wrote:H, I did try to write my own code for StrCmp for a 16F877A and it did also not work. :?:

The reason is that expressions like the one below are not correctly executed:

Code: Select all

var Shrt: short;
    S1, S2: string[10];
    I: word;
...
  I := 0;
  while (S1[I] > 0) and (S2[I] > 0) and (S1[I] = S2[I]) do
  begin
    Inc(I);
  end;
No matter if S1 differs from S[2] or not, the while loop is executed as long one of both chars is not zero.

Expression "S1 = S2" returns always true apparently. After some investigations it seems that "S1 < S2" and "S1 < S2" always return false.

Thanks in advance!

p.s. for P18 this type of code is executed correctly.

Ok, I found it. Fixed. Thanks.

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

#4 Post by Dany » 21 Apr 2009 14:04

Thanks srdjan! :D
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

Post Reply

Return to “mikroPascal PRO for PIC Beta Testing”