unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls, TeeProcs, TeEngine, Chart, Series, TypInfo;
type
TForm1 = class(TForm)
Chart1: TChart;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Series1: TBarSeries;
BitBtn3: TBitBtn;
ComboBox1: TComboBox;
BitBtn4: TBitBtn;
BitBtn5: TBitBtn;
CheckBox1: TCheckBox;
Label1: TLabel;
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
procedure BitBtn4Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ComboBox1Change(Sender: TObject);
procedure BitBtn5Click(Sender: TObject);
procedure CheckBox1Click(Sender: TObject);
private
public
end;
TNameSeries = (Bar,HorizBar,Line,Area,Point,Pie);
const
LMin : String = 'abcdefghijklmnñopqrstuvwxyz';
LMay : String = 'ABCDEFGHIJKLMNÑOPQRSTUVWXYZ';
var
Form1: TForm1;
F : TStringList;
CountLMin : Array[1..27] of Integer;
CountLMay : Array[1..27] of Integer;
FileProcess : Boolean;
implementation
{$R *.dfm}
procedure Reset;
begin
FileProcess := False;
FillChar(CountLMin,SizeOf(CountLMin),0);
FillChar(CountLMay,SizeOf(CountLMin),0);
with form1 do
begin
Series1.Clear;
ComboBox1.Text := ComboBox1.Items.Strings[0];
end;
end;
Procedure ReadTextFile(FileName : String);
var
i,j : Integer;
P : Integer;
C : String;
begin
FileProcess := False;
Reset;
F := TStringList.Create;
try
F.LoadFromFile(FileName);
except
MessageDlg('Error de I/O', mtinformation, [mbok], 0);
F.Free;
Exit;
end;
for i := 0 to F.Count-1 do
begin
for j := 1 to Length(F.Strings[i]) do
begin
C := Copy(F.Strings[i],j,1);
P := Pos(C,LMin);
if (P > 0) then
Inc(CountLMin[P]);
P := Pos(C,LMay);
if (P > 0) then
Inc(CountLMay[P]);
end;
end ;
FileProcess := True;
F.Free;
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
var
openDialog : TOpenDialog;
begin
openDialog := TOpenDialog.Create(self);
openDialog.InitialDir := GetCurrentDir;
openDialog.Options := [ofFileMustExist];
openDialog.Filter := 'Archivo de Texto a Graficar|*.txt';
openDialog.FilterIndex := 1;
if openDialog.Execute then
ReadTextFile(openDialog.FileName)
else
MessageDlg('No Se Proceso Ningún Archivo de Texto',mtinformation,[mbok],0);
openDialog.Free;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
var
C : String;
i : Integer;
begin
if not FileProcess then
begin
MessageDlg('Seleccione un Archivo de Texto',mtinformation,[mbok],0);
Exit;
end;
with Series1 do
begin
Clear;
for i := 1 to High(CountLMin) do
begin
C := Copy(LMin,i,1);
Add(CountLMin[i], C, clBlue);
end
end;
end;
procedure TForm1.BitBtn3Click(Sender: TObject);
var
C : String;
i : Integer;
begin
if not FileProcess then
begin
MessageDlg('Seleccione un Archivo de Texto',mtinformation,[mbok],0);
Exit;
end;
with Series1 do
begin
Clear;
for i := 1 to High(CountLMay) do
begin
C := Copy(LMay,i,1);
Add(CountLMay[i], C, clRed);
end
end;
end;
procedure TForm1.BitBtn4Click(Sender: TObject);
var
C : String;
i : Integer;
begin
if not FileProcess then
begin
MessageDlg('Seleccione un Archivo de Texto',mtinformation,[mbok],0);
Exit;
end;
with Series1 do
begin
Clear;
for i := 1 to High(CountLMay) do
begin
C := Copy(LMay,i,1);
Add(CountLMay[i]+CountLMin[i], C, clGreen);
end
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
NameSeries : String;
CountSeries : TNameSeries;
begin
for CountSeries := Low(TNameSeries) to High(TNameSeries) do
begin
NameSeries := GetEnumName(TypeInfo(TNameSeries),Integer(CountSeries));
ComboBox1.Items.Add(NameSeries);
end;
ComboBox1.Text := ComboBox1.Items.Strings[0];
CheckBox1.State := cbChecked;
end;
procedure TForm1.ComboBox1Change(Sender: TObject);
var
NameSeries : TNameSeries;
begin
NameSeries := TNameSeries(GetEnumValue(TypeInfo(TNameSeries),ComboBox1.Text));
Case NameSeries of
Bar : ChangeSeriesType(TChartSeries(Series1),TBarSeries);
HorizBar : ChangeSeriesType(TChartSeries(Series1),THorizBarSeries);
Line : ChangeSeriesType(TChartSeries(Series1),TLineSeries);
Area : ChangeSeriesType(TChartSeries(Series1),TAreaSeries);
Point : ChangeSeriesType(TChartSeries(Series1),TPointSeries);
Pie : ChangeSeriesType(TChartSeries(Series1),TPieSeries);
end;
end;
procedure TForm1.BitBtn5Click(Sender: TObject);
begin
Reset;
end;
procedure TForm1.CheckBox1Click(Sender: TObject);
begin
Chart1.View3D:=CheckBox1.Checked;
end;
end.