Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Bare7a committed Feb 24, 2018
1 parent 3ca498f commit 4d6cce9
Show file tree
Hide file tree
Showing 12 changed files with 448,729 additions and 0 deletions.
Binary file added Main.dcu
Binary file not shown.
132 changes: 132 additions & 0 deletions Main.dfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
object FormMain: TFormMain
Left = 0
Top = 0
BorderStyle = bsDialog
Caption = 'Word Finder'
ClientHeight = 494
ClientWidth = 262
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
Position = poDesktopCenter
OnShow = FormShow
PixelsPerInch = 96
TextHeight = 13
object Label_Characters: TLabel
Left = 6
Top = 33
Width = 38
Height = 13
Caption = 'Letters:'
end
object Label_Min: TLabel
Left = 6
Top = 62
Width = 59
Height = 13
Caption = 'Min Length: '
end
object Label_MaxCharacters: TLabel
Left = 133
Top = 62
Width = 63
Height = 13
Caption = 'Max Length: '
end
object Label_Language: TLabel
Left = 6
Top = 6
Width = 51
Height = 13
Caption = 'Language:'
end
object Label_WordsFound: TLabel
Left = 154
Top = 6
Width = 71
Height = 13
Caption = 'Words Found: '
end
object Label_WordsFoundNumber: TLabel
Left = 224
Top = 6
Width = 3
Height = 13
Caption = ' '
end
object Edit_Characters: TEdit
Left = 50
Top = 30
Width = 121
Height = 21
TabOrder = 1
end
object Button_FindWord: TButton
Left = 183
Top = 28
Width = 75
Height = 25
Caption = 'Find Word'
TabOrder = 6
OnClick = Button_FindWordClick
end
object Memo_Words: TMemo
Left = 6
Top = 91
Width = 252
Height = 396
Lines.Strings = (
'Memo_Words')
ReadOnly = True
ScrollBars = ssVertical
TabOrder = 7
end
object Edit_MinCharacters: TEdit
Left = 68
Top = 59
Width = 40
Height = 21
TabOrder = 2
Text = '0'
end
object UpDown_MinCharacters: TUpDown
Left = 110
Top = 59
Width = 16
Height = 21
Associate = Edit_MinCharacters
TabOrder = 3
OnClick = UpDown_MinCharactersClick
end
object Edit_MaxCharacters: TEdit
Left = 199
Top = 59
Width = 40
Height = 21
TabOrder = 4
Text = '0'
end
object UpDown_MaxCharacters: TUpDown
Left = 241
Top = 59
Width = 16
Height = 21
Associate = Edit_MaxCharacters
TabOrder = 5
OnClick = UpDown_MaxCharactersClick
end
object ComboBox_Language: TComboBox
Left = 61
Top = 3
Width = 86
Height = 21
ItemHeight = 13
TabOrder = 0
Text = 'Bulgarian'
OnSelect = ComboBox_LanguageSelect
end
end
159 changes: 159 additions & 0 deletions Main.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
unit Main;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls;

type
TFormMain = class(TForm)
Edit_Characters: TEdit;
Label_Characters: TLabel;
Button_FindWord: TButton;
Memo_Words: TMemo;
Edit_MinCharacters: TEdit;
Label_Min: TLabel;
UpDown_MinCharacters: TUpDown;
Label_MaxCharacters: TLabel;
Edit_MaxCharacters: TEdit;
UpDown_MaxCharacters: TUpDown;
Label_Language: TLabel;
ComboBox_Language: TComboBox;
Label_WordsFound: TLabel;
Label_WordsFoundNumber: TLabel;
procedure FormShow(Sender: TObject);
procedure Button_FindWordClick(Sender: TObject);
procedure UpDown_MinCharactersClick(Sender: TObject; Button: TUDBtnType);
procedure UpDown_MaxCharactersClick(Sender: TObject; Button: TUDBtnType);
procedure ComboBox_LanguageSelect(Sender: TObject);
private
{ Private declarations }
dictionary, dictionaryList : TStringList;
function ListFiles(const AFolder, AFilter: string) : TStringList;
public
{ Public declarations }
end;

var
FormMain: TFormMain;

implementation

{$R *.dfm}

procedure TFormMain.Button_FindWordClick(Sender: TObject);
var
minLength, maxlength, charPosition, wordsFound, i, j: integer;
charactersList, charactersListTemp : string;
wordPass : Boolean;
begin
minLength := UpDown_MinCharacters.Position;
maxLength := UpDown_MaxCharacters.Position;
charactersList := Edit_Characters.Text;

Memo_Words.Clear;
wordPass := False;
wordsFound := 0;

for i := 0 to dictionary.Count - 1 do
begin
if (Length(dictionary[i]) >= minLength) and (Length(dictionary[i]) <= maxLength) then
begin
charactersListTemp := charactersList;

for j := 1 to Length(dictionary[i]) do
begin
charPosition := AnsiPos(AnsiLowerCase(dictionary[i][j]), AnsiLowerCase(charactersListTemp));

if charPosition = 0 then
begin
wordPass := False;
Break;
end else
begin
Delete(charactersListTemp, charPosition, 1);
wordPass := True;
end;
end;

if wordPass then
begin
wordsFound := wordsFound + 1;
Memo_Words.Lines.Add(dictionary[i]);
end;
end;
end;

self.Label_WordsFoundNumber.Caption := IntToStr(wordsFound);
end;

procedure TFormMain.ComboBox_LanguageSelect(Sender: TObject);
begin
dictionary.Free;
dictionary := TStringList.Create;

dictionary.LoadFromFile('dictionaries\' + dictionaryList[ComboBox_Language.ItemIndex] + '.txt');;
end;

procedure TFormMain.FormShow(Sender: TObject);
var
I: Integer;
begin
Self.UpDown_MinCharacters.Position := 3;
Self.UpDown_MaxCharacters.Position := 8;

dictionaryList := ListFiles('dictionaries','*.txt');


ComboBox_Language.Items.BeginUpdate;
ComboBox_Language.Items.Clear;

for I := 0 to dictionaryList.Count - 1 do
ComboBox_Language.Items.Add(dictionaryList[i]);

ComboBox_Language.Items.EndUpdate;

ComboBox_Language.ItemIndex := 0;
ComboBox_Language.OnSelect(Sender);

Memo_Words.Clear;
end;

procedure TFormMain.UpDown_MaxCharactersClick(Sender: TObject;
Button: TUDBtnType);
begin
UpDown_MaxCharacters.Min := UpDown_MinCharacters.Position;
end;

procedure TFormMain.UpDown_MinCharactersClick(Sender: TObject;
Button: TUDBtnType);
begin
UpDown_MinCharacters.Max := UpDown_MaxCharacters.Position;
end;

function TFormMain.ListFiles(const AFolder, AFilter: string) : TStringList;
var
vFindHandle: THandle;
vFilter : String;
vFindData : WIN32_FIND_DATA;
vResult : TStringList;
begin
vResult := TStringList.Create;

try
vFilter := AFolder + '\' + AFilter;
vFindHandle := FindFirstFile(PChar(vFilter), vFindData);
// if vFindHandle = INVALID_HANDLE_VALUE then
// Exit;

repeat
vResult.Add(ChangeFileExt(vFindData.cFileName, ''));
until not FindNextFile(vFindHandle, vFindData);
Windows.FindClose(vFindHandle);
finally
Result := vResult;
end;
end;

end.
14 changes: 14 additions & 0 deletions WordsFinder.dpr
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
program WordsFinder;

uses
Forms,
Main in 'Main.pas' {FormMain};

{$R *.res}

begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TFormMain, FormMain);
Application.Run;
end.
36 changes: 36 additions & 0 deletions WordsFinder.dproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{20ad5fc5-a338-4138-ba4e-7c2e34123ca9}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<DCC_DCCCompiler>DCC32</DCC_DCCCompiler>
<DCC_DependencyCheckOutputName>WordsFinder.exe</DCC_DependencyCheckOutputName>
<MainSource>WordsFinder.dpr</MainSource>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Version>7.0</Version>
<DCC_DebugInformation>False</DCC_DebugInformation>
<DCC_LocalDebugSymbols>False</DCC_LocalDebugSymbols>
<DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
<DCC_Define>RELEASE</DCC_Define>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<Version>7.0</Version>
<DCC_Define>DEBUG</DCC_Define>
</PropertyGroup>
<ProjectExtensions>
<Borland.Personality>Delphi.Personality</Borland.Personality>
<Borland.ProjectType />
<BorlandProject>
<BorlandProject><Delphi.Personality><Parameters><Parameters Name="UseLauncher">False</Parameters><Parameters Name="LoadAllSymbols">True</Parameters><Parameters Name="LoadUnspecifiedSymbols">False</Parameters></Parameters><VersionInfo><VersionInfo Name="IncludeVerInfo">False</VersionInfo><VersionInfo Name="AutoIncBuild">False</VersionInfo><VersionInfo Name="MajorVer">1</VersionInfo><VersionInfo Name="MinorVer">0</VersionInfo><VersionInfo Name="Release">0</VersionInfo><VersionInfo Name="Build">0</VersionInfo><VersionInfo Name="Debug">False</VersionInfo><VersionInfo Name="PreRelease">False</VersionInfo><VersionInfo Name="Special">False</VersionInfo><VersionInfo Name="Private">False</VersionInfo><VersionInfo Name="DLL">False</VersionInfo><VersionInfo Name="Locale">2057</VersionInfo><VersionInfo Name="CodePage">1252</VersionInfo></VersionInfo><VersionInfoKeys><VersionInfoKeys Name="CompanyName"></VersionInfoKeys><VersionInfoKeys Name="FileDescription"></VersionInfoKeys><VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys><VersionInfoKeys Name="InternalName"></VersionInfoKeys><VersionInfoKeys Name="LegalCopyright"></VersionInfoKeys><VersionInfoKeys Name="LegalTrademarks"></VersionInfoKeys><VersionInfoKeys Name="OriginalFilename"></VersionInfoKeys><VersionInfoKeys Name="ProductName"></VersionInfoKeys><VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys><VersionInfoKeys Name="Comments"></VersionInfoKeys></VersionInfoKeys><Source><Source Name="MainSource">WordsFinder.dpr</Source></Source></Delphi.Personality></BorlandProject></BorlandProject>
</ProjectExtensions>
<Import Project="$(MSBuildBinPath)\Borland.Delphi.Targets" />
<ItemGroup>
<DelphiCompile Include="WordsFinder.dpr">
<MainSource>MainSource</MainSource>
</DelphiCompile>
<DCCReference Include="Main.pas">
<Form>FormMain</Form>
</DCCReference>
</ItemGroup>
</Project>
13 changes: 13 additions & 0 deletions WordsFinder.dproj.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<BorlandProject>
<Transactions>
<Transaction>2018/02/23 21:01:05.853.dproj,C:\Users\Bare7a\Documents\RAD Studio\Projects\Project1.dproj=C:\Users\Bare7a\Documents\RAD Studio\Projects\FindTheWord.dproj</Transaction>
<Transaction>2018/02/23 21:01:11.260.pas,C:\Users\Bare7a\Documents\RAD Studio\Projects\Unit1.pas=C:\Users\Bare7a\Documents\RAD Studio\Projects\Main.pas</Transaction>
<Transaction>2018/02/23 21:01:11.260.dfm,C:\Users\Bare7a\Documents\RAD Studio\Projects\Unit1.dfm=C:\Users\Bare7a\Documents\RAD Studio\Projects\Main.dfm</Transaction>
<Transaction>2018/02/23 21:01:26.316.pas,C:\Users\Bare7a\Documents\RAD Studio\Projects\Main.pas=C:\Users\Bare7a\Desktop\FindTheWord\Main.pas</Transaction>
<Transaction>2018/02/23 21:01:26.316.dfm,C:\Users\Bare7a\Documents\RAD Studio\Projects\Main.dfm=C:\Users\Bare7a\Desktop\FindTheWord\Main.dfm</Transaction>
<Transaction>2018/02/23 21:01:36.543.dproj,C:\Users\Bare7a\Documents\RAD Studio\Projects\FindTheWord.dproj=C:\Users\Bare7a\Desktop\FindTheWord\FindTheWord.dproj</Transaction>
<Transaction>2018/02/24 11:47:32.886.dproj,C:\Users\Bare7a\Desktop\FindTheWord\FindTheWord.dproj=C:\Users\Bare7a\Desktop\FindTheWord\WordFinder.dproj</Transaction>
<Transaction>2018/02/24 12:15:25.067.dproj,C:\Users\Bare7a\Desktop\FindTheWord\WordFinder.dproj=C:\Users\Bare7a\Desktop\FindTheWord\WordsFinder.dproj</Transaction>
</Transactions>
</BorlandProject>
Binary file added WordsFinder.exe
Binary file not shown.
34 changes: 34 additions & 0 deletions WordsFinder.groupproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{32769f49-d938-4303-b1a3-d73920ced686}</ProjectGuid>
</PropertyGroup>
<ItemGroup />
<ItemGroup>
<Projects Include="WordsFinder.dproj" />
</ItemGroup>
<ProjectExtensions>
<Borland.Personality>Default.Personality</Borland.Personality>
<Borland.ProjectType />
<BorlandProject>
<BorlandProject xmlns=""> <Default.Personality> </Default.Personality> </BorlandProject></BorlandProject>
</ProjectExtensions>
<Target Name="WordsFinder">
<MSBuild Projects="WordsFinder.dproj" Targets="" />
</Target>
<Target Name="WordsFinder:Clean">
<MSBuild Projects="WordsFinder.dproj" Targets="Clean" />
</Target>
<Target Name="WordsFinder:Make">
<MSBuild Projects="WordsFinder.dproj" Targets="Make" />
</Target>
<Target Name="Build">
<CallTarget Targets="WordsFinder" />
</Target>
<Target Name="Clean">
<CallTarget Targets="WordsFinder:Clean" />
</Target>
<Target Name="Make">
<CallTarget Targets="WordsFinder:Make" />
</Target>
<Import Condition="Exists('$(MSBuildBinPath)\Borland.Group.Targets')" Project="$(MSBuildBinPath)\Borland.Group.Targets" />
</Project>
Loading

0 comments on commit 4d6cce9

Please sign in to comment.