в Delphi я хочу заменить «Tform3.ListBox» в «Tform3.Listbox.Clear» на параметр.Какой тип данных я должен поместить туда? - PullRequest
0 голосов
/ 19 декабря 2018

Для моей процедуры я хотел поместить идентификатор в качестве параметра, но я не знаю, какой тип данных использовать, который знает метод .clear или может использоваться в TListBox.В этом примере я использовал строку, но это, очевидно, не работает.

procedure Reset(input, output: string);
begin
     input := '';
     output.Clear;

«input» - это мой Edit.text, поэтому я могу просто использовать строку для этого, но «output» - это мой ListBox.

весь мой код

unit UFunction;

interface
uses
  System.Classes,System.StrUtils,System.AnsiStrings,System.SysUtils;

 procedure CaseSensitiveSwitchFlip ;
 procedure CopyToClipboard;
 procedure Reset(Input: string; Output: string);
 procedure Sort(input: string);
implementation

uses
UInterface, Vcl.Clipbrd;

procedure CaseSensitiveSwitchFlip ;
begin
     IstCaseSensitiveActive := not IstCaseSensitiveActive
end;

procedure CopyToClipboard;
begin
     ClipBoard.AsText := Form3.ListeLb.Items.Text;
end;

procedure Reset(input: string; output: string);
begin
     input:='';
     output:= '';
end;

procedure Sort(input: string);
var
ArrayIndex, inputIndex, Count: integer;
Character: array[1..256] of string;
text: string;
begin
     if (input<>'') then begin
       if (input<>'') and (Form3.ListeLb.Items.Count <> 0)  then
         Form3.ListeLb.Clear;
       ArrayIndex:= 0;
         repeat
               if input<>'' then begin
                 ArrayIndex:= ArrayIndex +1;
                 if not IstCaseSensitiveActive then
                   input:= AnsiUpperCase(input);
                 Character[ArrayIndex]:= input[1];
                 Count:= 1;
                 inputIndex:= 0;
                 text:= (input);
                 delete(text, 1, 1);
                 input:= text;
                 if AnsiContainsStr(input, Character[ArrayIndex]) and (Character[ArrayIndex] <> ' ') then begin
                   repeat
                         inputIndex:= inputIndex +1;
                         if Character[ArrayIndex] = input[inputIndex] then begin
                           Count:= Count + 1;
                           text:= input;
                           delete(text, inputIndex, 1);
                           input:= text;
                           inputIndex:= inputIndex - 1;
                         end;
                   until not (AnsiContainsStr(input, Character[ArrayIndex])) or (Character[ArrayIndex] = ' ');
                   Form3.ListeLb.Items.Add(Character[ArrayIndex] + ': ' + IntToStr (Count))
                 end
                 else if (Character[ArrayIndex] <> ' ') then begin
                        Form3.ListeLb.Items.Add(Character[ArrayIndex] + ': ' + IntToStr (Count))
                 end;
               end;
         until (length(input) = 1) or (input = '');
         if input <> '' then begin
           ArrayIndex:= ArrayIndex + 1;
           Character[ArrayIndex]:= input[1];
           input := '';
           if Character[ArrayIndex] <> ' ' then
             Form3.ListeLb.Items.Add(Character[ArrayIndex] +': ' + IntToStr (1));
         end;
     end
end;

end.

1 Ответ

0 голосов
/ 19 декабря 2018

Вы должны просто изменить типы ввода параметров для вывода TEdit на TListBox

procedure reset(input:TEdit; output:TListBox)
begin
 input.Text:='';
 output.items.clear;
end;

Прошло много времени, когда я видел паскаль, а не объектный код без классов;

...