26.02.2016, 16:14
|
Прохожий
|
|
Регистрация: 12.02.2016
Сообщения: 3
Версия Delphi: Delphi 7
Репутация: 10
|
|
как ввести данные в код?
В программе я заполняю значения в Memo,как эти значения вписать в программу,чтобы не писать сто раз?
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Menus, jpeg, ExtCtrls, Buttons;
type
TForm1 = class(TForm)
Memo1: TMemo;
Memo2: TMemo;
Button1: TButton;
MainMenu1: TMainMenu;
Memo3: TMemo;
Memo4: TMemo;
Memo5: TMemo;
Memo7: TMemo;
Button2: TButton;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
fOpenDialog1: TOpenDialog;
fSaveDialog1: TSaveDialog;
Image1: TImage;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label1: TLabel;
Label6: TLabel;
Label7: TLabel;
BitBtn1: TBitBtn;
N4: TMenuItem;
N5: TMenuItem;
procedure Button1Click(Sender: TObject);
procedure N2Click(Sender: TObject);
procedure N3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
y: array[1..100] of integer;
s,s1,s2,s3: string;
a,b,i: integer;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var m:integer;
m1:string;
begin
s1 := '';
m1:=Memo3.Text;
m := Strtoint(m1);
s := Memo1.Text;
y[1] := Strtoint(Memo5.Text);
y[2] := Strtoint(Memo4.Text);
for i := 3 to Length(s) do
y[i] := (y[i-1]+y[i-2]) mod m;
for i := 1 to Length(s) do
s1 :=s1 + chr(ord(s[i]) XOR y[i]);
Memo2.Lines.Add(s1);
end;
procedure TForm1.N2Click(Sender: TObject);
begin
if fOpenDialog1.Execute then Memo1.Lines.LoadFromFile(fOpenDialog1.FileName);
end;
procedure TForm1.N3Click(Sender: TObject);
begin
if fSaveDialog1.Execute then Memo7.Lines.SaveToFile('Шифр.txt');
end;
procedure TForm1.Button2Click(Sender: TObject);
var m:integer;
begin
s2 := '';
m := Strtoint(Memo3.Text);
s3 := Memo2.Text;
y[1] := Strtoint(Memo5.Text);
y[2] := Strtoint(Memo4.Text);
for i := 3 to Length(s3) do
y[i] := (y[i-1]+y[i-2]) mod m;
for i := 1 to Length(s3) do
s2 :=s2 + chr(ord(s3[i]) xor y[i]);
Memo7.Lines.Add(s2);
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
Application.Terminate;
end;
end.
|