Replacing quotation marks
Sometimes a response contains double quotation marks that are escaped. This usually occurs when CompileExternalQualification uses a GetEntryList response. Such responses must be formatted correctly for the next request.
For example, this is a response from GetEntryList:
this.result={n:1,f:\[{t:4,v:"((('302830900'=\"NavCat_Tier01_01\")) OR
(('302830900'=\"NavCat_Tier01_03\")) OR
(('302830900'=\"NavCat_Tier01_10\"))) OR
('301453000' =\"- Global-\")"}, {ts:1176400022}]};
(('302830900'=\"NavCat_Tier01_03\")) OR
(('302830900'=\"NavCat_Tier01_10\"))) OR
('301453000' =\"- Global-\")"}, {ts:1176400022}]};
However, CompileExternalQualification, expects the response to look like this, where \" is replaced by ":
this.result={n:1,f:[{t:4,v:"((('302830900'="NavCat Tier01 01")) OR
('302830900'="NavCat Tier01 03")) OR
(('302830900'="NavCat Tier01 10"))) OR
('301453000' ="- Global -")"} , {ts:1176400022}]};
('302830900'="NavCat Tier01 03")) OR
(('302830900'="NavCat Tier01 10"))) OR
('301453000' ="- Global -")"} , {ts:1176400022}]};
You can use the following code to format the request:
function replaceQuote(inStr : string(500000))
var
n, i, endPos, nPrevPos, nStrLen : number;
nSlashPairCount : number;
aStrArray : array[300] of string(150);
tmpStr : string;
begin
// this.result={n:1,f:[{t:4,v:"(('302830900'=\"NavCat TierTag01 05\")) OR
//(('302830900'=\"NavCat TierTag01 07\"))"} ,{ts:1168290284} ]};
// First parse the value of v:
StrSearchDelimited(inStr, STRING_COMPLETE, inStr, "v:\"", 1, "\"},", 1,
STR SEARCH FIRST| STR SEARCH IGNORE WHITESPACES);
nStrLen := strlen(inStr);
nSlashPairCount := 0;
n := StrSearch(inStr, "\\\"", STR SEARCH FIRST);
while n <> 0 do
n := StrSearch(inStr, "\\\"", STR SEARCH NEXT);
//this overcounts so we compensate by not counting the first strsearch.
nSlashPairCount := nSlashPairCount + 1;
end;
// parse:
if nSlashPairCount >= 1 then
i := 1;
endPos := StrSearch(inStr,"", STR SEARCH FIRST);
SubStr(inStr, aStrArray\[i\],1, endPos-1);
nPrevPos := endPos;
end;
for i:= 2 to nSlashPairCount do
endPos := StrSearch(inStr,"", STR SEARCH NEXT);
SubStr(inStr, aStrArray\[i\],nPrevPos+2, endPos-(nPrevPos+2));
nPrevPos := endPos;
end;
if nSlashPairCount > 2 then
//get the last part of the string
SubStr(inStr, aStrArray\[i\],nPrevPos+2, (nStrLen+1)-(nPrevPos+2));
end;
// now reassemble string with new delimiters
for i:=1 to nSlashPairCount do
gsEntQualForCompile := gsEntQualForCompile + aStrArray\[i\] + """;
end;
if nSlashPairCount = 0 then
gsEntQualForCompile := " ";
else
gsEntQualForCompile := gsEntQualForCompile + aStrArray\[i\];
end;
// for plugin qual
for i:=1 to nSlashPairCount do
gsEntQual := gsEntQual + aStrArray\[i\] \+"\"";
end;
if nSlashPairCount = 0 then
gsEntQual := " ";
else
gsEntQual := gsEntQual + aStrArray\[i\];
end;
end replaceQuote;
Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*