An obscure piece of code from Jade, 1997
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function TJadeMainForm.PseudoUpper(iStr: string): string; | |
var | |
stNum: string; | |
stDes: string; | |
stNam: string; | |
stPre: string; | |
stTmp: string; | |
begin | |
if JadeTable.State <> dsEdit then JadeTable.Edit; | |
iStr := Trim(LowerCase(iStr)); | |
stNum:=''; | |
stDes:=''; | |
stNam:=''; | |
//street number | |
while (Length(iStr)>0) and (iStr[1] in ['0'..'9']) do begin | |
stNum:=stNum + Copy(iStr, 1, 1); | |
Delete(iStr, 1, 1); | |
end; | |
//bis stuff | |
//dilimiter | |
while (Length(iStr)>0) and (iStr[1] in [' ',',','.']) do Delete(iStr, 1, 1); | |
//ch., rue, etc... | |
while (Length(iStr)>0) and (iStr[1] in ['a'..'z','à'..'ÿ']) do begin | |
stDes:=stDes+iStr[1]; | |
Delete(iStr, 1, 1); | |
end; | |
if (CompareText(stDes, 'chemin') = 0) or | |
(CompareText(stDes, 'ch') = 0) or | |
(CompareText(stDes, 'chem') = 0) | |
then stDes := 'ch. ' else | |
if (CompareText(stDes, 'r') = 0) or | |
(CompareText(stDes, 'rue') = 0) | |
then stDes := 'rue ' else | |
if (CompareText(stDes, 'route') = 0) or | |
(CompareText(stDes, 'rte') = 0) | |
then stDes := 'rte ' else | |
if (CompareText(stDes, 'avenue') = 0) or | |
(CompareText(stDes, 'av') = 0) | |
then stDes := 'av. ' else | |
if (CompareText(stDes, 'q') = 0) or | |
(CompareText(stDes, 'quai') = 0) | |
then stDes := 'quai ' else | |
if (CompareText(stDes, 'place') = 0) or | |
(CompareText(stDes, 'pl') = 0) | |
then stDes := 'pl. ' else | |
if (Length(stDes) > 0) then begin | |
stDes[1]:=UpCase(stDes[1]); | |
stNam:=stDes; | |
stDes:=''; | |
end; | |
if Length(iStr) > 0 then | |
while iStr[1] in [' ',',','.'] do Delete(iStr, 1, 1); | |
try | |
stPre:=''; | |
while (Length(iStr)>0) do begin | |
stTmp:=''; | |
while (Length(iStr)>0) and (iStr[1] in ['a'..'z','à'..'ÿ']) do begin | |
stTmp:=stTmp + iStr[1]; | |
Delete(iStr, 1, 1); | |
end; | |
if (CompareText(stTmp, 'd') = 0) then stPre:=stPre + stTmp else | |
if (CompareText(stTmp, 'de') = 0) then stPre:=stPre + stTmp + ' ' else | |
if (CompareText(stTmp, 'sur') = 0) then stPre:=stPre + stTmp + ' ' else | |
if (CompareText(stTmp, 'la') = 0) then stPre:=stPre + stTmp + ' ' else | |
if (CompareText(stTmp, 'du') = 0) then stPre:=stPre + stTmp + ' ' else | |
if (CompareText(stTmp, 'des') = 0) then stPre:=stPre + stTmp + ' ' else | |
if (CompareText(stTmp, 'le') = 0) then stPre:=stPre + stTmp + ' ' else | |
if (CompareText(stTmp, 'les') = 0) then stPre:=stPre + stTmp + ' ' else | |
if (CompareText(stTmp, 'en') = 0) then stPre:=stPre + stTmp + ' ' else | |
begin | |
if (Length(stTmp)>0) then begin | |
stTmp[1]:=upCase(stTmp[1]); | |
if (Length(stNam)>0) and (stTmp[1] <> '''') and (stTmp[1] <> '-') then stNam:=stNam + ' '; | |
end; | |
stNam:=stNam + stTmp; | |
while (Length(iStr)>0) and (not(iStr[1] in [',','.','0'..'9'])) do begin | |
stNam:=stNam + iStr[1]; | |
Delete(iStr, 1, 1); | |
if stNam[Length(stNam)] in ['''','-',' ','0'..'9'] then begin | |
if (CompareText(Copy(iStr, 1, Length('de')), 'de') <> 0) and | |
(CompareText(Copy(iStr, 1, Length('de')), 'd') <> 0) and | |
(CompareText(Copy(iStr, 1, Length('sur')), 'sur') <> 0) and | |
(CompareText(Copy(iStr, 1, Length('la')), 'la') <> 0) and | |
(CompareText(Copy(iStr, 1, Length('du')), 'du') <> 0) and | |
(CompareText(Copy(iStr, 1, Length('des')), 'des') <> 0) and | |
(CompareText(Copy(iStr, 1, Length('le')), 'le') <> 0) and | |
(CompareText(Copy(iStr, 1, Length('les')), 'les') <> 0) and | |
(CompareText(Copy(iStr, 1, Length('en')), 'en') <> 0) then | |
iStr[1]:=UpCase(iStr[1]); | |
end; | |
end; | |
break; | |
end; | |
while ((Length(iStr)>0) and (iStr[1] in [' '])) do Delete(iStr, 1, 1); | |
end; | |
while (Length(iStr) > 0) and (iStr[1] in [' ',',','.']) do Delete(iStr, 1, 1); | |
if StNum = '' then begin | |
while (Length(iStr)>0) and (iStr[1] in ['0'..'9']) do begin | |
stNum:=stNum + Copy(iStr, 1, 1); | |
Delete(iStr, 1, 1); | |
end; | |
end; | |
except | |
end; | |
Result:=''; | |
if StNum <> '' then Result:=Result + StNum + ', '; | |
if StDes <> '' then Result:=Result + StDes; | |
if StPre <> '' then Result:=Result + StPre; | |
if StNam <> '' then Result:=Result + Trim(StNam); | |
if iStr <> '' then Result:=Result + Trim(iStr); | |
end; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Did your "Jade" software ended up being used at "La Poste" (french postal system) ? That could explain why La Poste failed so often to deliver my mail... :)