Hi,
Het is nu voor de 2e keer dat ik bemerk dat MatchText (in System.StrUtils) niet doet wat die zou moeten doen. Eerder met een string zoeken in een exception (E.Message) en nu in een JSON.
In deze JSON (RESTResponse.JSONText) kan MatchText de string "error_message" (zonder quotes) niet vinden.
Code:
{ "error_message":"The provided Place ID is no longer valid. Please refresh cached Place IDs as per https://developers.google.com/maps/documentation/places/web-service/place-id#save-id",
"html_attributions":
[
]
,
"status":"NOT_FOUND"
}
Code:
if System.StrUtils.MatchText( RESTResponse.JSONText, [ 'error_message', 'NOT_FOUND' ]) then
...
Met
Code:
if AnsiContainsText( RESTResponse.JSONText, 'error_message') then
...
lukt het wel.
MatchText is via diverse functies uiteindelijk in System.SysUtils:
Code:
function AnsiCompareText(const S1, S2: string): Integer;
begin
Result := CompareString(LOCALE_USER_DEFAULT, NORM_IGNORECASE, PChar(S1),
Length(S1), PChar(S2), Length(S2)) - CSTR_EQUAL;
end;
...
Ik gebruik MatchText (case insensitive, MatchStr = case sensitive) regelmatig maar waarom dit niet goed gaat? Wie kan me vertellen wat ik over het hoofd zie?
Bookmarks