From 637a621c1c59d44b6339b1578556a322e1c0e7f1 Mon Sep 17 00:00:00 2001 From: Ivan Mahonin Date: Jan 18 2019 17:48:28 +0000 Subject: lazarus: calc --- diff --git a/lazarus/calc/project1.ico b/lazarus/calc/project1.ico new file mode 100644 index 0000000..0341321 Binary files /dev/null and b/lazarus/calc/project1.ico differ diff --git a/lazarus/calc/project1.lpi b/lazarus/calc/project1.lpi new file mode 100644 index 0000000..3afe492 --- /dev/null +++ b/lazarus/calc/project1.lpi @@ -0,0 +1,79 @@ + + + + + + + + + <ResourceType Value="res"/> + <UseXPManifest Value="True"/> + <Icon Value="0"/> + </General> + <i18n> + <EnableI18N LFM="False"/> + </i18n> + <VersionInfo> + <StringTable ProductVersion=""/> + </VersionInfo> + <BuildModes Count="1"> + <Item1 Name="Default" Default="True"/> + </BuildModes> + <PublishOptions> + <Version Value="2"/> + </PublishOptions> + <RunParams> + <local> + <FormatVersion Value="1"/> + </local> + </RunParams> + <RequiredPackages Count="1"> + <Item1> + <PackageName Value="LCL"/> + </Item1> + </RequiredPackages> + <Units Count="2"> + <Unit0> + <Filename Value="project1.lpr"/> + <IsPartOfProject Value="True"/> + </Unit0> + <Unit1> + <Filename Value="unit1.pas"/> + <IsPartOfProject Value="True"/> + <ComponentName Value="Form1"/> + <ResourceBaseClass Value="Form"/> + <UnitName Value="Unit1"/> + </Unit1> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="11"/> + <Target> + <Filename Value="project1"/> + </Target> + <SearchPaths> + <IncludeFiles Value="$(ProjOutDir)"/> + <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> + </SearchPaths> + <Linking> + <Options> + <Win32> + <GraphicApplication Value="True"/> + </Win32> + </Options> + </Linking> + </CompilerOptions> + <Debugging> + <Exceptions Count="3"> + <Item1> + <Name Value="EAbort"/> + </Item1> + <Item2> + <Name Value="ECodetoolError"/> + </Item2> + <Item3> + <Name Value="EFOpenError"/> + </Item3> + </Exceptions> + </Debugging> +</CONFIG> diff --git a/lazarus/calc/project1.lpr b/lazarus/calc/project1.lpr new file mode 100644 index 0000000..58c35dc --- /dev/null +++ b/lazarus/calc/project1.lpr @@ -0,0 +1,21 @@ +program project1; + +{$mode objfpc}{$H+} + +uses + {$IFDEF UNIX}{$IFDEF UseCThreads} + cthreads, + {$ENDIF}{$ENDIF} + Interfaces, // this includes the LCL widgetset + Forms, Unit1 + { you can add units after this }; + +{$R *.res} + +begin + RequireDerivedFormResource:=True; + Application.Initialize; + Application.CreateForm(TForm1, Form1); + Application.Run; +end. + diff --git a/lazarus/calc/project1.res b/lazarus/calc/project1.res new file mode 100644 index 0000000..e994dfa Binary files /dev/null and b/lazarus/calc/project1.res differ diff --git a/lazarus/calc/unit1.lfm b/lazarus/calc/unit1.lfm new file mode 100644 index 0000000..697e753 --- /dev/null +++ b/lazarus/calc/unit1.lfm @@ -0,0 +1,77 @@ +object Form1: TForm1 + Left = 244 + Height = 399 + Top = 209 + Width = 598 + Caption = 'Form1' + ClientHeight = 399 + ClientWidth = 598 + LCLVersion = '1.6.2.0' + object Edit1: TEdit + Left = 8 + Height = 38 + Top = 8 + Width = 184 + TabOrder = 0 + Text = '2' + end + object Edit2: TEdit + Left = 8 + Height = 38 + Top = 88 + Width = 184 + TabOrder = 1 + Text = '3' + end + object Edit3: TEdit + Left = 8 + Height = 38 + Top = 168 + Width = 184 + TabOrder = 2 + end + object Button1: TButton + Left = 8 + Height = 25 + Top = 53 + Width = 40 + Caption = '+' + OnClick = Button1Click + TabOrder = 3 + end + object Button2: TButton + Left = 56 + Height = 25 + Top = 53 + Width = 40 + Caption = '-' + OnClick = Button2Click + TabOrder = 4 + end + object Button3: TButton + Left = 104 + Height = 25 + Top = 53 + Width = 40 + Caption = '*' + OnClick = Button3Click + TabOrder = 5 + end + object Button4: TButton + Left = 152 + Height = 25 + Top = 53 + Width = 40 + Caption = '/' + OnClick = Button4Click + TabOrder = 6 + end + object Memo1: TMemo + Left = 200 + Height = 376 + Top = 8 + Width = 384 + ScrollBars = ssBoth + TabOrder = 7 + end +end diff --git a/lazarus/calc/unit1.pas b/lazarus/calc/unit1.pas new file mode 100644 index 0000000..a4b60c0 --- /dev/null +++ b/lazarus/calc/unit1.pas @@ -0,0 +1,85 @@ +unit Unit1; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls; + +type + + { TForm1 } + + TForm1 = class(TForm) + Button1: TButton; + Button2: TButton; + Button3: TButton; + Button4: TButton; + Edit1: TEdit; + Edit2: TEdit; + Edit3: TEdit; + Memo1: TMemo; + procedure Button1Click(Sender: TObject); + procedure Button2Click(Sender: TObject); + procedure Button3Click(Sender: TObject); + procedure Button4Click(Sender: TObject); + private + { private declarations } + public + { public declarations } + end; + +var + Form1: TForm1; + +implementation + +{$R *.lfm} + +procedure TForm1.Button1Click(Sender: TObject); +var + a, b, c: single; +begin + a := StrToFloat(Edit1.Text); + b := StrToFloat(Edit2.Text); + c := a + b; + Edit3.Text := FloatToStr(c); + Memo1.Lines.Add(Edit1.Text + ' + ' + Edit2.Text + ' = ' + Edit3.Text); +end; + +procedure TForm1.Button2Click(Sender: TObject); +var + a, b, c: single; +begin + a := StrToFloat(Edit1.Text); + b := StrToFloat(Edit2.Text); + c := a - b; + Edit3.Text := FloatToStr(c); + Memo1.Lines.Add(Edit1.Text + ' - ' + Edit2.Text + ' = ' + Edit3.Text); +end; + +procedure TForm1.Button3Click(Sender: TObject); +var + a, b, c: single; +begin + a := StrToFloat(Edit1.Text); + b := StrToFloat(Edit2.Text); + c := a * b; + Edit3.Text := FloatToStr(c); + Memo1.Lines.Add(Edit1.Text + ' * ' + Edit2.Text + ' = ' + Edit3.Text); +end; + +procedure TForm1.Button4Click(Sender: TObject); +var + a, b, c: single; +begin + a := StrToFloat(Edit1.Text); + b := StrToFloat(Edit2.Text); + c := a / b; + Edit3.Text := FloatToStr(c); + Memo1.Lines.Add(Edit1.Text + ' / ' + Edit2.Text + ' = ' + Edit3.Text); +end; + +end. +