Mega Code Archive

 
Categories / Delphi / Examples
 

Strcomp

procedure TForm1.TempFindMatch(dictWord: String); {check dictionary word against user word and see if they match string comparison routines can be a little unpredictable in Delphi -you SHOULD be able to say if StrOne = StrTwo then ... (where both StrOne and StrTwo are String types that is) but sometimes that works and sometimes it doesn't. Converting string to PChar types and using StrComp() DOES work though} var userWordPC,dictWordPC: PChar; compResult: Integer; begin userWordPC := 'tree'; dictWordPC := PChar(dictWord); compResult := StrComp(userWordPC, dictWordPC); if (compResult = 0) then begin ShowMessage('match found for tree'); end; end;