一个没有了解透的简单函数: BoolToStr
2008-05-15 12:27
423 查看
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); end; var Form1: TForm1; implementation {$R *.dfm} //以前不知道 BoolToStr 还有一个默认参数 procedure TForm1.Button1Click(Sender: TObject); var b: Boolean; s: string; begin b := True; s := BoolToStr(b); ShowMessage(s); {-1} b := False; s := BoolToStr(b); ShowMessage(s); {0} b := True; s := BoolToStr(b, True); ShowMessage(s); {True} b := False; s := BoolToStr(b, True); ShowMessage(s); {False} end; //以前还曾得意的这样用过, 笑话了. procedure TForm1.Button2Click(Sender: TObject); const b2s: array[Boolean] of string = ('False', 'True'); var b: Boolean; s: string; begin b := True; s := b2s[b]; ShowMessage(s); {True} b := not b; s := b2s[b]; ShowMessage(s); {False} end; end.
SysUtils 单元下的公用函数目录
相关文章推荐
- strcpy()函数一个简单那程序来了解一下它。。
- 编写一个函数 char *strfind(char *s, char *t),用于查找字符串t在字符串s中最右边出现的位置,如果没有找到则返回NULL.
- 全国计算机等级二级C++第四章习题编程题6 :编写一个函数 char *strfind(char *s, char *t),用于查找字符串t在字符串s中最右边出现的位置,如果没有找到则返回NULL.
- 一个超简单,输出main函数返回值的函数,且是测试没有return语句的情况下哦~
- 【C语言】为下面的函数原型编写函数定义: int ascii_to_integer(char *str); 这个字符串参数必须包含一个或者多个数字,函数应该把这些数字字符转换为整数并返回这个整数。
- 例题:把一个超市购物的题做成函数。这个题做成函数没有必要,但可以了解输入参数,输出参数,返回值,函数体,还有结构体,ArryList集合,for循环算结果,以及集合里 .count的使用
- 非常简单的一个函数 竟然一直没有使用 find()
- 为下面的函数原型编写函数定义: int ascii_to_integer(char *str); 这个字符串参数必须包含一个或者多个数字,函数应该把这些数字字符转换为整数并返回这个整数。如果字符串参数
- int ascii_to_integer(char *str); 这个字符串参数必须包含一个或者多个数字,函数应该把这些数字字符转换为整数并返回这个整数。
- 显示了一个左右删除的功能(都是用的div) , 还有没有简单一点的写法 , html前端知识
- 在$x_0$处全导数可逆的函数$f:\mathbf{R^n}\to\mathbf{R^n}$的一个性质
- 用 React.js 写一个最简单的 To-do List 应用
- 使用linux系统函数和c++03类写的一个简单线程池
- 简单的计数器。。。。(scanf和getchar()的区别)。。。(一个错误很久没有找出来,最后是一个回车,中文下面的回车,编译不支持)
- 写的一个简单的分割字符串的函数(附原码)
- C语言 将一个数字字符串转换成这个字符串对应的数字(包括正浮点数、负浮点数 函数原型:double my_atof(char *str)
- Android中调用C++函数的一个简单Demo
- js实现类似php中strtotime函数和timetostr的日期转换/互换功能
- sql server 一个简单的函数
- 在Linux下利用替换函数(exec函数家族)写一个简单的myshell