Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Unit1;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls;
- type
- TForm1 = class(TForm)
- Memo1: TMemo;
- Button1: TButton;
- Button2: TButton;
- OpenDialog1: TOpenDialog;
- Label1: TLabel;
- procedure Button1Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form1: TForm1;
- implementation
- {$R *.dfm}
- var
- F:Textfile;
- wordcount:integer;
- S:string;
- procedure Counter(S:string;wordcount:integer);
- var wobe,i:integer;
- begin
- wobe:=0;
- For i:=1 to Length(S) do
- begin
- If ((wobe=0) and (S[i]<>' '))
- then
- begin
- Inc(wordcount);
- wobe:=1;
- end
- else
- begin
- If ((wobe=1) and (S[i]=' ')) then wobe:=0;
- end;
- end;
- end;
- procedure TForm1.Button1Click(Sender: TObject);
- begin
- if OpenDialog1.Execute then
- Memo1.Lines.LoadFromFile(OpenDialog1.FileName);
- end;
- procedure TForm1.Button2Click(Sender: TObject);
- var j:integer;
- begin
- wordcount:=0;
- for j:=1 to Memo1.Lines.Count do
- begin
- S:=Memo1.Lines[j];
- Counter(S,wordcount);
- end;
- Label1.Caption:=IntToStr(wordcount);
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement