获取打印页号列表
作者:互联网
获取打印页号列表
posted on 2011-06-28 11:18 万一 阅读(1589) 评论(1) 编辑 收藏
procedure SplitCommaCross(aList: TStrings); procedure SPlitCross(aList: TStrings); var LList: TStrings; a,b: Integer; i: Integer; begin if Pos('-', aList.Text) < 2 then Exit; LList := TStringList.Create; ExtractStrings(['-'], [' '], PChar(aList.Text), LList); if LList.Count = 2 then begin aList.Clear; a := StrToIntDef(LList[0], 0); b := StrToIntDef(LList[1], -1); for i := a to b do aList.Add(IntToStr(i)); end; LList.Free; end; var LList,RList: TStrings; s: string; begin aList.CommaText := Trim(aList.Text); LList := TStringList.Create; RList := TStringList.Create; for s in aList do begin LList.Text := Trim(s); SPlitCross(LList); RList.AddStrings(LList); end; aList.Assign(RList); LList.Free; RList.Free; end; //测试 var str: string; List: TStrings; begin str := '1-3,5-6,8'; List := TStringList.Create; List.Text := Trim(str); SplitCommaCross(List); ShowMessage(List.Text); //1 2 3 5 6 8 List.Free; end;
posted on 2011-06-28 11:18 万一 阅读(1589) 评论(1) 编辑 收藏
标签:end,TStrings,获取,List,打印,aList,列表,LList,Text 来源: https://blog.51cto.com/u_14617575/2795041