I'm currently writing an application in which I have a function as follows:
var a,b,c, algorithm: string
begin
a := some-operations-with-regular-expressions;
b := some-other-operation-with-regular-expressions;
c := just-similar-to-b-but-different;
algorithm := IniFile.ReadString('XML Info','AlgorithmExpression', '');
//algorithm is fetched like 'http://wwww.urlhere' + a + '/' + b + '/' + c
DoDownload (algorithm, true);
end;
Now what I expected was to have a, b & c automatically replaced with the values of the variables with the same name, but it appears that I'm so wrong. Is there any way to get the result of the algorithm variable composed of the strings between '' and the variable values?
Any suggestion (even if it calls for major redesigning) would be much appreciated.
Thanks, sphynx
I didn't understand what you are trying to do, but here goes a shot.
IniFile should contain something like this:
[XML Info]
AlgorithmExpression=http://wwww.urlhere[<a>]/[<b>]/[<c>]
and you could do something like this:
algorithm := IniFile.ReadString('XML Info','AlgorithmExpression', '');
algorithm := StringReplace(algorithm,'[<a>]',a,[]);
algorithm := StringReplace(algorithm,'[<b>]',b,[]);
algorithm := StringReplace(algorithm,'[<c>]',c,[]);
DoDownload (algorithm, true);
If this is about formatting, Delphi also has the C style format command:
var
output: String;
begin
output := Format('http://%s/%s/%s', ['this', 'that', 'otherthing']);
ShowMessage(output);
end;
Shows the message:
http://this/that/otherthing
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With