Bog*_*atu 4 delphi string variables casting
我正在编写一个应用程序,其中我有如下函数:
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;
Run Code Online (Sandbox Code Playgroud)
现在我的期望是a,b&c自动替换为具有相同名称的变量的值,但看起来我错了.有没有办法让算法变量的结果由''和变量值之间的字符串组成?
任何建议(即使它要求重大的重新设计)都将非常感激.
谢谢,sphynx
Chr*_*ian 11
我不明白你想要做什么,但这里有所帮助.
IniFile应包含以下内容:
[XML Info]
AlgorithmExpression=http://wwww.urlhere[<a>]/[<b>]/[<c>]
Run Code Online (Sandbox Code Playgroud)
你可以做这样的事情:
algorithm := IniFile.ReadString('XML Info','AlgorithmExpression', '');
algorithm := StringReplace(algorithm,'[<a>]',a,[]);
algorithm := StringReplace(algorithm,'[<b>]',b,[]);
algorithm := StringReplace(algorithm,'[<c>]',c,[]);
DoDownload (algorithm, true);
Run Code Online (Sandbox Code Playgroud)
如果这是关于格式化,Delphi也有C风格格式命令:
var
output: String;
begin
output := Format('http://%s/%s/%s', ['this', 'that', 'otherthing']);
ShowMessage(output);
end;
Run Code Online (Sandbox Code Playgroud)
显示消息:
归档时间: |
|
查看次数: |
1018 次 |
最近记录: |