Replacing backslashes in SilkPerformer scripts
To fix the duplication, replace the double backslashes with a single backslash as follows:
function replaceBackSlash(inStr : string(10000)) : string
var
n, i, endPos : number;
nSlashPairCount : number;
aStrArray : array[300] of string(75);
tmpStr : string;
sResult : string;
begin
sResult := "";
n := StrSearch(inStr, "\\\\", STR SEARCH FIRST);
while n <> 0 do
n := StrSearch(inStr, "\\\\", STR SEARCH NEXT);
nSlashPairCount := nSlashPairCount + 1;
end;
// parse:
1\\1\\4\\1\\1\\302792000\\2\\6\\1000\\4\\1\\1\\160\\2\\1\\21\\4\\1\\2\\2\\1\\2\\2\\1\\
if nSlashPairCount >= 1 then
i := 1;
endPos := StrSearch(inStr,"\\", STR SEARCH FIRST);
SubStr(inStr, aStrArray\[i\],1, endPos-1);
i := 2;
end;
if nSlashPairCount >= 2 then
StrSearchDelimited(aStrArray[i], STRING_COMPLETE, inStr, "\\\\", 1, "\\\\", 1,
STR SEARCH FIRST | STR SEARCH IGNORE WHITESPACES);
end;
for i:= 3 to nSlashPairCount do
StrSearchDelimited(aStrArray[i], STRING COMPLETE, inStr, "\\\\", 1, "\\\\", 1,
STR SEARCH NEXT | STR SEARCH IGNORE WHITESPACES);
end;
// now reassemble string with new delimiters
for i:=1 to nSlashPairCount do
sResult := sResult + aStrArray [i] + "\\";
end;
replaceBackSlash := sResult;
end replaceBackSlash;
var
n, i, endPos : number;
nSlashPairCount : number;
aStrArray : array[300] of string(75);
tmpStr : string;
sResult : string;
begin
sResult := "";
n := StrSearch(inStr, "\\\\", STR SEARCH FIRST);
while n <> 0 do
n := StrSearch(inStr, "\\\\", STR SEARCH NEXT);
nSlashPairCount := nSlashPairCount + 1;
end;
// parse:
1\\1\\4\\1\\1\\302792000\\2\\6\\1000\\4\\1\\1\\160\\2\\1\\21\\4\\1\\2\\2\\1\\2\\2\\1\\
if nSlashPairCount >= 1 then
i := 1;
endPos := StrSearch(inStr,"\\", STR SEARCH FIRST);
SubStr(inStr, aStrArray\[i\],1, endPos-1);
i := 2;
end;
if nSlashPairCount >= 2 then
StrSearchDelimited(aStrArray[i], STRING_COMPLETE, inStr, "\\\\", 1, "\\\\", 1,
STR SEARCH FIRST | STR SEARCH IGNORE WHITESPACES);
end;
for i:= 3 to nSlashPairCount do
StrSearchDelimited(aStrArray[i], STRING COMPLETE, inStr, "\\\\", 1, "\\\\", 1,
STR SEARCH NEXT | STR SEARCH IGNORE WHITESPACES);
end;
// now reassemble string with new delimiters
for i:=1 to nSlashPairCount do
sResult := sResult + aStrArray [i] + "\\";
end;
replaceBackSlash := sResult;
end replaceBackSlash;
Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*