当前位置:首页 » 软件开发
开发技术指南» 文章正文
    引言: 首部 function AnsiResemblesTex
 

 

    摘要: if not exists (select * from dbo.sysobjects where id = object_id(n[indextable]) and objectproperty(id, nisusertable) = 1)create table indextable(ex char(20), num integer) go create procedure setind......
    摘要: borland亚太地区产品总监的旧文章:让用户可用脚本控制你的应用程序 ......


字符串函数大全

    

      首部 function ansiresemblestext(const atext, aother: string): boolean; 【程序编程相关:终于看到了传说中的Delphi9以及我的

【推荐阅读:先人的DELPHI基础开发技巧

      $[strutils.pas 【扩展信息:进程、窗口句柄、文件属性、程序运行状态

      功能 返回两个字符串是否相似

      说明 ansi(american national standards institute)美国国家标准协会;不区分大小写

      参考 function strutils.soundexproc; var strutils.ansiresemblesproc

      例子 checkbox1.checked := ansiresemblestext(edit1.text, edit2.text);

      ━━━━━━━━━━━━━━━━━━━━━

      首部 function ansicontainstext(const atext, asubtext: string): boolean;

      $[strutils.pas

      功能 返回字符串atext是否包含子串asubtext

      说明 不区分大小写

      参考 function strutils.ansiuppercase; function strutils.ansipos

      例子 checkbox1.checked := ansicontainstext(edit1.text, edit2.text);

      ━━━━━━━━━━━━━━━━━━━━━

      首部 function ansistartstext(const asubtext, atext: string): boolean;

      $[strutils.pas

      功能 返回字符串atext是否以子串asubtext开头

      说明 不区分大小写

      参考 function windows.comparestring

      例子 checkbox1.checked := ansistartstext(edit1.text, edit2.text);

      ━━━━━━━━━━━━━━━━━━━━━

      首部 function ansiendstext(const asubtext, atext: string): boolean;

      $[strutils.pas

      功能 返回字符串atext是否以子串asubtext结尾

      说明 不区分大小写

      参考 function windows.comparestring

      例子 checkbox1.checked := ansiendstext(edit1.text, edit2.text);

      ━━━━━━━━━━━━━━━━━━━━━

      首部 function ansireplacetext(const atext, afromtext, atotext: string):

      string; $[strutils.pas

      功能 返回字符串atext中用子串afromtext替换成子串atotext的结果

      说明 不区分大小写

      参考 function sysutils.stringreplace; type sysutils.treplaceflags

      例子 edit4.text := ansireplacetext(edit1.text, edit2.text, edit3.text);

      ━━━━━━━━━━━━━━━━━━━━━

      首部 function ansimatchtext(const atext: string; const avalues: array of

      string): boolean; $[strutils.pas

      功能 返回字符串数组avalues中是否包含字符串atext

      说明 不区分大小写

      参考 function strutils.ansiindextext

      例子 checkbox1.checked := ansimatchtext(edit1.text, [a1, a2, a3,

      a4]);

      ━━━━━━━━━━━━━━━━━━━━━

      首部 function ansiindextext(const atext: string; const avalues: array of

      string): integer; $[strutils.pas

      功能 返回字符串atext在字符串数组avalues中的位置

      说明 不区分大小写;如果不包含则返回-1

      参考 function sysutils.ansisametext

      例子 spinedit1.value := ansiindextext(edit1.text, [a1, a2, a3, a4]);

      ━━━━━━━━━━━━━━━━━━━━━

      首部 function ansicontainsstr(const atext, asubtext: string): boolean;

      $[strutils.pas

      功能 返回字符串atext是否包含子串asubtext

      说明 区分大小写

      参考 function strutils.ansipos

      例子 checkbox1.checked := ansicontainsstr(edit1.text, edit2.text);

      ━━━━━━━━━━━━━━━━━━━━━

      首部 function ansistartsstr(const asubtext, atext: string): boolean;

      $[strutils.pas

      功能 返回字符串atext是否以子串asubtext开头

      说明 区分大小写

      参考 function sysutils.ansisamestr

      例子 checkbox1.checked := ansistartsstr(edit1.text, edit2.text);

      ━━━━━━━━━━━━━━━━━━━━━

      首部 function ansiendsstr(const asubtext, atext: string): boolean;

      $[strutils.pas

      功能 返回字符串atext是否以子串asubtext结尾

      说明 区分大小写

      参考 function sysutils.ansisamestr

      例子 checkbox1.checked := ansiendsstr(edit1.text, edit2.text);

      ━━━━━━━━━━━━━━━━━━━━━

      首部 function ansireplacestr(const atext, afromtext, atotext: string):

      string; $[strutils.pas

      功能 返回字符串atext中用子串afromtext替换成子串atotext的结果

      说明 区分大小写

      参考 function sysutils.stringreplace; type sysutils.treplaceflags

      例子 edit4.text := ansireplacestr(edit1.text, edit2.text, edit3.text);

      ━━━━━━━━━━━━━━━━━━━━━

      首部 function ansimatchstr(const atext: string; const avalues: array of

      string): boolean; $[strutils.pas

      功能 返回字符串数组avalues中是否包含字符串atext

      说明 区分大小写

      参考 function strutils.ansiindexstr

      例子 checkbox1.checked := ansimatchstr(edit1.text, [a1, a2, a3,

a4]);

      ━━━━━━━━━━━━━━━━━━━━━

      首部 function ansiindexstr(const atext: string; const avalues: array of

      string): integer; $[strutils.pas

      功能 返回字符串atext在字符串数组avalues中的位置

      说明 区分大小写

      参考 function sysutils.ansisamestr

      例子 spinedit1.value := ansiindexstr(edit1.text, [a1, a2, a3, a4]);

      ━━━━━━━━━━━━━━━━━━━━━

      首部 function dupestring(const atext: string; acount: integer): string;

      $[strutils.pas

      功能 返回字符串atext的acount个复本

      说明 当acount为0时返回

      参考 function system.setlength

      例子 edit3.text := dupestring(edit1.text, spinedit1.value);

      ━━━━━━━━━━━━━━━━━━━━━

      首部 function reversestring(const atext: string): string; $[strutils.pas

      功能 返回字符串atext的反序

      说明 reversestring(1234) = 4321

      参考 function system.setlength

      例子 edit3.text := reversestring(edit1.text);

      ━━━━━━━━━━━━━━━━━━━━━

      首部 function stuffstring(const atext: string; astart, alength: cardinal;

      const asubtext: string): string; $[strutils.pas

      功能 返回嵌套字符串

      说明 astart:嵌套开始位置;alength:嵌套长度;stuffstring(abcd, 2, 0, 12) = a12bcd

      参考 function system.copy

      例子 edit3.text := stuffstring(edit1.text, spinedit1.value, spinedit2.value,

      edit2.text);

      ━━━━━━━━━━━━━━━━━━━━━

      首部 function randomfrom(const avalues: array of string): string; overload;

      $[strutils.pas

      功能 随机返回字符串数组avalues中的一个元素

      说明 之前建议执行randomize

      参考 function system.random

      例子 randomize; edit3.text := randomfrom([a1, a2, a3, a4]);

      ━━━━━━━━━━━━━━━━━━━━━

      首部 function ifthen(avalue: boolean; const atrue: string; afalse: string =

      ): string; overload; $[strutils.pas

      功能 返回指定的逻辑字符串

      说明 ifthen(true, 是, 否) = 是;ifthen(false, 是, 否) = 否

      参考 <null>

      例子 edit3.text := ifthen(checkbox1.checked, edit1.text, edit2.text);

      ━━━━━━━━━━━━━━━━━━━━━

      首部 function leftstr(const atext: string; const acount: integer): string;

      $[strutils.pas

      功能 返回字符串atext左边的acount个字符

      说明 leftstr(123456, 3) = 123

      参考 function system.copy

      例子 edit3.text := leftstr(edit1.text, spinedit1.value);

      ━━━━━━━━━━━━━━━━━━━━━

      首部 function rightstr(const atext: string; const acount: integer): string;

      $[strutils.pas

      功能 返回字符串atext右边的acount个字符

      说明 rightstr(123456, 3) = 456

      参考 function system.copy

      例子 edit3.text := rightstr(edit1.text, spinedit1.value);

      ━━━━━━━━━━━━━━━━━━━━━

      首部 function midstr(const atext: string; const astart, acount: integer):

      string; $[strutils.pas

      功能 返回字符串atext从astart开始的acount个字符

      说明 其实就是copy

      参考 function system.copy

      例子 edit3.text := midstr(edit1.text, spinedit1.value, spinedit2.value);

      ━━━━━━━━━━━━━━━━━━━━━

      首部 function searchbuf(buf: pchar; buflen: integer; selstart, sellength:

      integer; searchstring: string; options: tstringsearchoptions = [sodown]):

      pchar; $[strutils.pas

      功能 返回第一个搜索到的指针位置

      说明 这函数常用于文本中搜索字符串

      参考 <null>

      例子

      ///////begin searchbuf

      function searchedit(editcontrol: tcustomedit; const searchstring: string;

      searchoptions: tstringsearchoptions; findfirst: boolean = false): boolean;

      var

      buffer, p: pchar;

      size: word;

      begin

      result := false;

      if (length(searchstring) = 0) then exit;

      size := editcontrol.gettextlen;

      if (size = 0) then exit;

      buffer := stralloc(size + 1);

      try

      editcontrol.gettextbuf(buffer, size + 1);

      p := searchbuf(buffer, size, editcontrol.selstart, editcontrol.sellength,

      searchstring, searchoptions);

      if p <> nil then begin

      editcontrol.selstart := p - buffer;

      editcontrol.sellength := length(searchstring);

      result := true;

      end;

      finally

      strdispose(buffer);

      end;

      end;

      procedure tform1.button1click(sender: tobject);

      var

      searchoptions: tstringsearchoptions;

      begin

      searchoptions := [];

      if checkbox1.checked then

      include(searchoptions, sodown);

      if checkbox2.checked then

      include(searchoptions, somatchcase);

      if checkbox3.checked then


...   下一页
 ·borland人物介绍    »显示摘要«
    摘要: http://www.delphidevelopers.com/borland/borland_somebody.htm ......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE