有关函数调用的问题(100)

  • 主题发起人 主题发起人 yufeiguan
  • 开始时间 开始时间
Y

yufeiguan

Unregistered / Unconfirmed
GUEST, unregistred user!
unit MyTStringsCustomSort; //自定义的 TStringList 排列类型interfaceuses Windows, SysUtils, Variants, Classes, Controls, StdCtrls;type TSortData = array of TStringList;procedure MyStringsCustomSort(var aData: TSortData; SortIndex, SortType: Integer; SortFlg: Bool); //自定义排序implementationuses unit1;//-------数字排序 1function NumberSort_1(List: TStringList; Index1, Index2: Integer): Integer;var Value1, Value2: Integer;begin Result := 0; try Value1 := StrToInt(List[Index1]); Value2 := StrToInt(List[Index2]); if Value1 > Value2 then Result := -1 else if Value1 < Value2 then Result := 1 else Result := 0; except end;end;//-------数字排序 2function NumberSort_2(List: TStringList; Index1, Index2: Integer): Integer;var Value1, Value2: Integer;begin Result := 0; try Value1 := StrToInt(List[Index1]); Value2 := StrToInt(List[Index2]); if Value1 > Value2 then Result := 1 else if Value1 < Value2 then Result := -1 else Result := 0; except end;end;//-------日期排序 1function DateTimeSort_1(List: TStringList; Index1, Index2: Integer): Integer;var Value1, Value2: TDateTime;begin Result := 0; try Value1 := StrToDateTime(List[Index1]); Value2 := StrToDateTime(List[Index2]); if Value1 > Value2 then Result := -1 else if Value1 < Value2 then Result := 1 else Result := 0; except end;end;//-------日期排序 2function DateTimeSort_2(List: TStringList; Index1, Index2: Integer): Integer;var Value1, Value2: TDateTime;begin Result := 0; try Value1 := StrToDateTime(List[Index1]); Value2 := StrToDateTime(List[Index2]); if Value1 > Value2 then Result := 1 else if Value1 < Value2 then Result := -1 else Result := 0; except end;end;//-------字符串排序 1function StrSort_1(List: TStringList; Index1, Index2: Integer): Integer;var Value1, Value2: Integer;begin Result := 0; try Result := -CompareStr(List[Index1], List[Index2]); except end;end;//-------字符串排序 2function StrSort_2(List: TStringList; Index1, Index2: Integer): Integer;var Value1, Value2: Integer;begin Result := 0; try Result := CompareStr(List[Index1], List[Index2]); except end;end;//-------排列字符串组单元--------//SortIndex 要排列的 数据行 ID//SortType 排列类型 0 大小, 1 时间,3 文字//SortFlg 顺序还是反序procedure MyStringsCustomSort(var aData: TSortData; SortIndex, SortType: Integer; SortFlg: Bool); //自定义排序var tls: TStringList; SwpStrs: TStringList; i: integer; Array_i: Integer;begin tls := TStringList.Create; SwpStrs := TStringList.Create; try for i := 0 to aData[SortIndex].Count - 1 do tls.AddObject(aData[SortIndex], TObject(i)); case sortType of 0: case SortFlg of //数字大小排列数据 True: tls.CustomSort(NumberSort_1); False: tls.CustomSort(NumberSort_2); end; 1: case SortFlg of //日期大小排列数据 True: tls.CustomSort(DateTimeSort_1); False: tls.CustomSort(DateTimeSort_2); end; 2: case SortFlg of //文字顺序排列数据 True: tls.CustomSort(StrSort_1); False: tls.CustomSort(StrSort_2); end; end; for Array_i := 0 to High(aData) do begin SwpStrs.Clear; for i := 0 to tls.Count - 1 do SwpStrs.Append(aData[Array_i][integer(tls.Objects)]); aData[Array_i].Text := SwpStrs.Text; end; finally tls.Free; SwpStrs.Free; end;end;end.上面是一个单元文件,问题如下:当调用函数MyStringsCustomSort时候,MyStringsCustomSort调用的NumberSort_1,NumberSort_2,DateTimeSort_1,DateTimeSort_2,StrSort_1,StrSort_1的参数是什么,如果写全(就是把参数也写出来,那么MyStringsCustomSort函数应该是怎么样的?)
 
后退
顶部