Recent

Author Topic: StrComp problem(Solved)  (Read 505 times)

JLWest

  • Hero Member
  • *****
  • Posts: 1293
StrComp problem(Solved)
« on: April 01, 2023, 01:32:45 am »
Trying to compare two strings;
I don't understand what wrong with this.
Didn't know it mattered.
It compiled. I haven't tested it yet.

Sometimes just sName=sTag works and sometimes not. Wonder why?

Code: Pascal  [Select][+][-]
  1. VAR
  2.  P1 : PChar;
  3.  P2 : PChar;  
  4.  C: SizeInt;
  5. aName,aTag: String;
  6. begin
  7.  
  8. P1:=sName;             <<<duplicates.pas(243,10) Error: Incompatible types: got "AnsiString" expected "PChar"
  9. p2:=sTag;
  10. C:= strcomp(P1,P2);
  11.  
« Last Edit: May 11, 2023, 01:07:26 am by JLWest »
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: StrComp problem
« Reply #1 on: April 01, 2023, 01:36:55 am »
I do not know why you hide your declaration of sName, anyway, "P1 := PChar(sName);" should solve your issue.
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

 

TinyPortal © 2005-2018