About StrIComp function in Turbo Pascal

I always have a message of "Type Mismatch" of the following

result := StrIComp(S1,S2);

where S1 and S2 are "String" type.  What's wrong with it?
HenryChangAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

My name is MudSystems EngineerCommented:
They have to be PCHAR type...


Var
  S1,S2: PChar;
  Result: Integer;

result := StrIComp(S1,S2);
0
bakry99Commented:
hi
s1 & s2 most be PCHAR
but if you want them String you most write a Function like this
Function StriComp(s1, s2:String):Integer;
begin
if s1>s2 then
 StriComp:=1
else
 if
  s1<s2 then
    striComp:=-1
 else
  striComp:=0;
end;

Bakry
0
bakry99Commented:
hi
s1 & s2 most be PCHAR
but if you want them String you most write a Function like this
Function StriComp(s1, s2:String):Integer;
begin
if s1>s2 then
 StriComp:=1
else
 if
  s1<s2 then
    striComp:=-1
 else
  striComp:=0;
end;

Bakry
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

ElnazearCommented:
it's very nice answer
Good Bakry99
 Elnazear
0
HenryChangAuthor Commented:
but s1 < s2 is case sensitive, eg. abd is larger than Abc.
0
My name is MudSystems EngineerCommented:
USES
  Strings;
var
 Result: PChar;
 S1, S2: String;
begin
 Readln(S1);
 Readln(S2);
 if StrIComp(@S1, @S2) = 0 then
   Result := 'equal'
 else
   Result := 'different';
 Writeln('They are ', Result);
end.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
My name is MudSystems EngineerCommented:
Hey... this was a good answer, why the "B" for???
0
bakry99Commented:
hi
  olso StrIComp(@S1, @S2)  is caseSensitive
  bakry
0
My name is MudSystems EngineerCommented:
>>abd is larger than Abc

But ofcourse... what do you expect...

StrIComp is not Case Sensitive

If you input:

  this is a test
  ThIs iS a tEsT


the result should be "equal".
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Pascal

From novice to tech pro — start learning today.