[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

About StrIComp function in Turbo Pascal

Posted on 2000-01-18
9
Medium Priority
?
198 Views
Last Modified: 2010-04-16
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?
0
Comment
Question by:HenryChang
9 Comments
 
LVL 6

Expert Comment

by:My name is Mud
ID: 2365876
They have to be PCHAR type...


Var
  S1,S2: PChar;
  Result: Integer;

result := StrIComp(S1,S2);
0
 
LVL 1

Expert Comment

by:bakry99
ID: 2366112
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
 
LVL 1

Expert Comment

by:bakry99
ID: 2366118
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
Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

 

Expert Comment

by:Elnazear
ID: 2366715
it's very nice answer
Good Bakry99
 Elnazear
0
 

Author Comment

by:HenryChang
ID: 2369738
but s1 < s2 is case sensitive, eg. abd is larger than Abc.
0
 
LVL 6

Accepted Solution

by:
My name is Mud earned 60 total points
ID: 2369753
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
 
LVL 6

Expert Comment

by:My name is Mud
ID: 2369859
Hey... this was a good answer, why the "B" for???
0
 
LVL 1

Expert Comment

by:bakry99
ID: 2370194
hi
  olso StrIComp(@S1, @S2)  is caseSensitive
  bakry
0
 
LVL 6

Expert Comment

by:My name is Mud
ID: 2370209
>>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

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It's not just another paperwork submission. Serious planning and rigour to managing the whole thought processes need to be put in place. The intent is not on drilling into the details, but to share tips in getting the first thing right to kick-start…
A recent study by Google illustrates that almost 84% of patients go for both online and offline sources for hospital research. What do you think, “Is the Healthcare Industry the next to be disrupted by Digital Marketing?”
How to fix display issue, screen flickering issue when I plug in power cord to the machine. Before I start explaining the solution lets check out once the issue how it looks like after I connect the power cord. most of you also have faced this…
Free Data Recovery software is an advanced solution from Kernel Tools to recover data and files such as documents, emails, database, media and pictures, etc. It supports recovery from physical & logical drive after a hard disk crash, accidental/inte…
Suggested Courses

590 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question