原创 将指定分隔符分隔的字符串转换为字符串列表收藏

//--------------------------------------------------------------------------------
// 功能:将指定分隔符分隔的字符串转换为字符串列表。
//             此函数在需要将
// 参数:
//             pcString : string; 字符串
//             pcChar   : string; 分隔符
//             pDesList :  TStringList   字符串列表
// 例如:
//  var tmpFldList : TStrings ;
//  begin
//      tmpFldList := TStringList.Create ;
//      StrToStringList(  Uppercase(pcFields), ',' , tmpFldList  );
//      ......
//      tmpFldList.Free ;
//  end;
//--------------------------------------------------------------------------------

Procedure StrToStringList( pcString,pcChar:string; pDesList : TStringList ) ; overload ;
var cAddStr,cSrcStr : string ;
    nPos : integer ;
begin
  pDesList.Clear ;

  cSrcStr := pcString ;
  while True do
  begin
     nPos := pos( pcChar, cSrcStr );
     if nPos = 0 then begin
        pDesList.Add( cSrcStr ) ;
        Exit ;
     end
     else begin
        cAddStr := copy( cSrcStr,1, nPos - 1 );
        pDesList.Add( cAddStr ) ;
        Delete( cSrcStr,1, nPos + length( pcChar )-1 );
     end;
  end;
end;

发表于 @ 2005年08月08日 17:07:00|评论(loading...)

新一篇: 显示或隐藏客户端页面中包含指定文字的DIV 标签 | 旧一篇: 修改记录字段值时错误Row cannot be located for updating的解决方法

Csdn Blog version 3.1a
Copyright © ForestK