你最喜欢的一段程序代码?

huangjin6133 2003-09-01 07:32:07
大家好!想发起一个问题,就是大家都做了这么久的编程了,有没有自己最喜欢的一段程序代码呢?不管是什么语言,我觉得精彩就可以,也可以用伪代码表示,再说说你喜欢它的理由,OK?
...全文
35 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
huangjin6133 2003-09-05
  • 打赏
  • 举报
回复
可能大家误解我的意思了,我应该想要的是比较精彩的算法吧!:)请大家继续,OK?
47522341 2003-09-01
  • 打赏
  • 举报
回复
个人认为:代码嘛,只要是自己写的,都没什么区别,
当时觉得再怎么好的代码,过一段时间好像都可以找到更好的来代替之,^_^,
tonylk 2003-09-01
  • 打赏
  • 举报
回复
function EncodeUnicodeSQL(Value:WideString):String;
//encode the widestring to string of unicode ascii set
//be used for search unicode char in SQL server
//2003.03.21
var
I:Integer;
begin
Result:='';
for I:=1 to Length(Value) do begin
if I>1 then begin
Result:=Result+'+';
end;
Result:=Result+'NCHAR('+IntToStr(Word(Value[I]))+')';
end;
end;
tonylk 2003-09-01
  • 打赏
  • 举报
回复
{$INCLUDE define.inc}
unit {$IFDEF UNICODE}TLMUObject{$ELSE}TLMObject{$ENDIF};

interface

uses
Windows, Messages, SysUtils, Classes, {$IFDEF UNICODE}TLMUSystem{$ELSE}TLMSystem{$ENDIF};

type
{$IFDEF UNICODE}TtlmUObject{$ELSE}TtlmObject{$ENDIF} = class(TObject, ILangIntf)
private
FOwner:TObject;

...
zhoutian618 2003-09-01
  • 打赏
  • 举报
回复
try
//执行语句.
except
raise Exception.Create('您输入的数据有问题!');
end;
Eastunfail 2003-09-01
  • 打赏
  • 举报
回复
随手写的,没有经过测试。用来在程序中通过代码设置断点,而在发行的EXE中这些断电不会导致错误。用法例如:
myAssert(CompareText(Edit1.Text,'stop')=0); //当Edit1.text为stop的时候就停下来调试



procedure myAssert(cond:boolean);
begin
if cond then Debug_;
end;
procedure Debug_;assembler;
const dll='kernel32.dll';Entry='IsDebuggerPresent';
asm
push dll
call LoadLibrary
push eax
push Entry
push eax
call GetProcAddress
call eax
cmp eax,false
je @@exit
int 3
@@exit:
call FreeLibrary
end;
fhuibo 2003-09-01
  • 打赏
  • 举报
回复
with query do
begin
close;
sql.clear;
sql.add('select * from table');
try
execsql;
except
showmessage('error');
end;
end;

理由是经常用
ttllhh 2003-09-01
  • 打赏
  • 举报
回复
我学的好累。。。
yckxzjj 2003-09-01
  • 打赏
  • 举报
回复
Close

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧