易截截图软件、单文件、免安装、纯绿色、仅160KB

delphi学习 字符串切割问题(split)

最近做一个项目,要用Delphi,以前从未学过,好是费劲啊,哈哈光是字符串切割这个问题就困扰了几个小时,通过查资料终于解决,在这与大家分享一下
Function split(src: pchar; ch: char):TStringList;
// 分割字符串
var
  i: Integer;
  tmp : string;
begin
  Result:=TStringList.Create;
  tmp := '';
  showmessage(src);
  showmessage(inttostr(Length(src)));
  for i := 0 to Length(src) do
  begin
    if src[i] <> ch then
    begin
      tmp := tmp + src[i];
    end
    else
    begin
      Result.Add(tmp);
      tmp := '';
    end;
  end;   
  Result.Add(tmp);
end;
说明一下,有些人用Pos函数来对字符串分割,这个函数对中文处理不了,所以最好不要用,
调用方法
先定义一个 var AStrings: TStringList;
在下面使用时 AStrings:=TStringList.Create;然后AStrings:=FaClass.split(pchar(AStr),'|');就把分割后的数组保存在了AStrings中了


相关文档:

翻译一半的Delphi汇编帮助

 The built-in assembler allows you to write assembly code within Delphi programs. It has the following features:
内嵌的汇编器允许在delphi程序中书写汇编代码,他有如下特性:
Allows for inline assembly
允许内嵌汇编
    Supports all instructions found in the Intel Pentium III, In ......

Delphi编译指令说明

《Delphi下深入Windows核心编程》(附录A Delphi编译指令说明)
摘抄人:麻子 qq:71892967
Delphi快速高小的编译器主要来自Object PASCAL的严谨,使用Delphi随时都在与编译器交流,大部分情况下不需要干涉编译器的运行,但是有时也需要对编译器进行必要的设置。
*************************************************** ......

Delphi文件操作

 unit unitFileOP;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
implementation
function GetSys32Dir:String;
var
Sys32Dir: string;
pSys32Dir: array[0..Max_Path] of char;
begin
GetSystemDirectory(pSys32Dir,Max_Pat ......

Delphi PureAPIWindow program

program PureAPIWindow;
uses
SysUtils,
Windows,
Messages;
const
WinClassName = 'DvsClass';
StrOut = 'Davis TextOut';
//窗口回调函数
function MyWinProc(
hWindow: HWND;
aMessage: UINT;
WParam: WPARAM;
LParam: LPARAM): LRESULT; stdcall; export; ......

Delphi 的RTTI机制浅探(续)

http://www.delphibbs.com/delphibbs/dispq.asp?LID=2421470
本文是《Delphi 的RTTI机制浅探》的续篇,上篇地址在:
  http://www.delphibbs.com/delphibbs/dispq.asp?lid=2420610
本文上篇基本上是
RTTI 入门介绍,续篇介绍了所有 TypInfo.pas 中的函数,附加了 Classes.pas、Graphics.pas、Controls.pas
中的 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号