注册 登录
编程论坛 Delphi论坛

[求助]请教Format函数的一用法

luperfect 发布于 2005-10-07 15:36, 1417 次点击
在执行SQL语句时,经常用到format函数,如:mysql:=format('select * from abc where name=''%s'', count=%d',[...]);
其中,%s代表字符型,%d代表数值型,但如果要代表一个逻辑型变量(true/false),如何表示呢?
1 回复
#2
makebest2005-10-21 20:19
这个问题根本就是 DELPHI 的问题,顺便答一下吧,的确没有找到逻辑类型的格式化描述,但是总有办法解决:
var
    s:string;
    function tf(t:boolean):string;
    begin
        if t then result:='true' else result:='false';
    end;
begin
    s:=format('It''s %s',[tf(true)]);
    showmessage(s);
end;
1