.


:




:

































 

 

 

 





- . , , , . .

:

.dpr. , View Source ( ) Project.

 

1 .

 

1. - program FuntToKg; uses Forms, Unit1 in 'Unit1.pas' {Form1}; {$R *.RES} begin Application.Initialize; Application.Title:= '-'; Application.CreateForm(TForm1, Form1); Application.Run; end.

 

Program, , . , . uses : Forms Unti1.pas

{$R *.RES} , , , , . , , , .res

:

, . , , Resource Workshop. Image Editor, Image Editor Tools.

begin end. .

, , . .

2 .

2. - unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Edit1: TEdit; Label1: TLabel; Label2: TLabel; Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.DFM} procedure TForm1.Button1Click(Sender: TObject); var f:real;// k:real;// begin f:=StrToFloat(Edit1.Text);// Edit1 k:=f*0.4059; label2.Caption:=Edit1.text+' (/) '+ FloatToStr(k)+ ' '; end; end.

 

unit, . uses .

: , .

( interface) , . , , (), type.

implementation , , .

{$R *.DFM}, , , .dfm. DFM . 3 unit1.dfm . Delphi .

 

3. unit1.dfm - object Form1: TForm1 Left = 191 Top = 108 Width = 290 Height = 185 Caption = '-' Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'MS Sans Serif' Font.Style = [] OldCreateOrder = False PixelsPerInch = 96 TextHeight = 13 object Label1: TLabel Left = 24 Top = 16 Width = 250 Height = 13 Caption = ' <>' end object Label2: TLabel Left = 24 Top = 80 Width = 121 Height = 73 WordWrap = True end object Edit1: TEdit Left = 24 Top = 48 Width = 121 Height = 21 TabOrder = 0 end object Button1: TButton Left = 160 Top = 48 Width = 75 Height = 25 Caption = '' TabOrder = 1 OnClick = Button1Click end end

{$R *.DFM} . , .

. begin end. ( ), begin .

, Delphi. , Delphi, , ( type).

()

, , . Pascal . , .

- , . . .

, . .

:

: file of _;

:

res: file of char; { }

numb: file of integer; { }

, , . :

: TextFile;

. , , , .. .

AssignFile, .

AssignFile :

AssignFile(var f, _: string);

Windows . , .. , .

, :

AssignFile(f,'c:\Windows\1.txt');

AssignFile(f,'\students\results.txt');

, , :

AssignFile(f,'config.cfg');

write writeln. :

write(_, _);

, _ - , , .

_ - , . .

, f TextFile, x1 x2 :

write(f, ' : ',x1,x2);

write writeln , writeln , , " ".

. , , , , . , : . .

:

( , )

( , )

, , Rewrite(f), f - TextFile.

, , Append(f), f - TextFile.

, . . "", - "". "" (Button1) 3 . "" 3 .

. "" (Button1). :

 

4. procedure TForm1.Button1Click(Sender: TObject); var f:TextFile; i:integer; begin AssignFile(f,'D:\test.txt');{ } Rewrite(f); { } for i:=1 to 3 do writeln(f,' ',i);{ } CloseFile(f);{ } end;

 

D: test.txt. :

1

2

3

5 , "".

 

5. procedure TForm1.Button2Click(Sender: TObject); var f:TextFile; i:integer; begin AssignFile(f,'D:\test.txt');{ } Append(f);{ } for i:= 4 to 6 do writeln(f,' ',i);{} CloseFile(f);{ } end;

 

, test.txt :

1

2

3

4

5

6

"", "", .

5 .

:

 

6. unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.DFM} procedure TForm1.Button1Click(Sender: TObject); var f:TextFile; i:integer; begin AssignFile(f,'D:\test.txt');{ } Rewrite(f); { } for i:=1 to 3 do writeln(f,' ',i);{ } CloseFile(f);{ } end; procedure TForm1.Button2Click(Sender: TObject); var f:TextFile; i:integer; begin AssignFile(f,'D:\test.txt');{ } Append(f);{ } for i:= 4 to 6 do writeln(f,' ',i);{} CloseFile(f);{ } end; end.

 

. . , , ( ). - .

. , IOResult (Input - Output Result - -). IOResult 0, - , - .

, -, . - {$I-}, - ( , ). {$I+}, -.

:

???

- (.. )

-

, .

AssignFile(f,'D:\testfile.txt');
{$I-}
Append(f);{ }
{$I+}

If IOResult <> 0 //..
then Rewrite(f);//

. Close. close - . :

Close(f);

CloseFile(f);





:


: 2016-11-18; !; : 277 |


:

:

. .
==> ...

1449 - | 1415 -


© 2015-2024 lektsii.org - -

: 0.034 .