Bonjour à toutes et à tous,
Dans un programme, je souhaite comparer deux chaînes. Je fais dans une fonction que j'appelle de la manière suivante :
où Adherents est du type :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 Txt:= Copy(txLibelle.text, LgIntro, 255); txNumAdh.Text:= IntToStr(AdhToNoAdh(Txt));
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 TAdherent = record NoAdh: Integer; DateInscript: string; Section: Integer; {Permet de répartir les adhérents par sections} Civilite: Integer; Nom: string; Prenom: string; ... end; TAdherents = array of TAdherent; ... Adherents: TAdherents;
La fonction est la suivante :
Impossible d'obtenir une comparaison, même en utilisant toutes les différentes possibilités offertes par Lazarus :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 function AdhToNoAdh(NomAdh: string): Integer; {Retourne le N° d'adhérent "NoAdh" correspondant à son Nom.} var i: Integer; Str1, Str2: string; begin Result:= -1; for i:= 0 to High(Adherents) do begin Str1:= AnsiLowerCase(Adherents[i].Nom); Str2:= AnsiLowerCase(NomAdh); if AnsiCompareText(Str1, Str2) = 0 then // if Str1 = Str2 then begin Result:= Adherents[i].NoAdh; Break; end; end; end;
Name Description
AnsiCompareStr Compare two strings
AnsiCompareText Compare two strings, case insensitive
AnsiLowerCase Convert string to all-lowercase
AnsiStrComp Compare strings case-sensitive
AnsiStrIComp Compare strings case-insensitive
AnsiStrLComp Compare L characters of strings case sensitive
AnsiStrLIComp Compare L characters of strings case insensitive
AnsiStrLower Convert string to all-lowercase
AnsiStrUpper Convert string to all-uppercase
AnsiUpperCase Convert string to all-uppercase
CompareStr Compare two strings case sensitive
CompareText Compare two strings case insensitive
Je crois les avoir essayées pratiquement toutes, rien n'y fait.
Je n'y comprends plus rien.
Avez-vous des idées ?
(Lazarus 0.9.30 sur Windows XP SP3)
Merci de votre aide.
Partager