44
© 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential. 第5第 ‟ 第第 第 第第第第„ 第第第第 2 ププププププププププププププププププ DELPHI 第第

【DELPHI / C++BUILDER STARTER チュートリアルシリーズ】 シーズン2 Delphi の部 第5回 「配列 と レコード 」

  • Upload
    -

  • View
    63

  • Download
    0

Embed Size (px)

Citation preview

PowerPoint

5 2Delphi

2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.

Delphi / C++Builder Starter 22017123 327 9 17 00~17 50 Delphi 1700~1720 / C++Builder 1730~1750 2120171232130 326 4213Function Procedure (5220 6227 736 83139327

Webhttp://forms.embarcadero.com/starter-tutorial-webinar

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.#embtwebi_jp

5

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.#embtwebi_jp

Delphi 10.1 Berlin Starter Edition

EDN*EDN

https://goo.gl/CCBNdx

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.#embtwebi_jp

(Integer iDate

: typevar:

Low, High ,Length, CopyiDate[1]iDate[2]iDate[3]iDate[4]iDate[5]iDate[6]iDate[7]

28262330323126

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.#embtwebi_jp

: typevar: typevarSetLength

typevarUnit

typevar

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.#embtwebi_jp

type (array)typevar // : ;//type //type = array [()] of ; //typeTDayTemperaturs = array [1..24] of Integer; //[a..x]var //myDayTemp1 : TDayTemperaturs;

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.#embtwebi_jp

[ ] TypeTDayTemperaturs=array[1..31] of Integer; [1]~[31] //procedure var //myDayTemp1 : TDayTemperaturs; // : begin myDayTemp[1] := 30; // [] myDayTemp[2] := 32; // myDayTemp[24] := 29; // myDayTemp[32] := 28; //end;

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.#embtwebi_jp

type (array)type var // : ;//type //type = array of ; // //typeTDayTemperaturs = array of Integer; var //myDayTemp1 : TDayTemperaturs;

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.#embtwebi_jp

SetLength(, 0 -1 SetLength(myDayTemp1,28); [0]~[27] //procedure var // myDayTemp1 : TDayTemperaturs; I : Integer;begin //SetLength (, ; SetLength(myDayTemp1,28); //28[0]~[27] for I := Low(myDayTemp1) to High(myDayTemp1) do //Low, High myDayTemp1[I] := [I]; // []end;

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.#embtwebi_jp

[]

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.#embtwebi_jp

SetLength

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.#embtwebi_jp

var :=

SetLength

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.#embtwebi_jp

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.#embtwebi_jp

var DoutekiArray, DoutekiArrayCopy: array of Integer; // SeitekiArray, SeitekiArrayCopy: Array [0 .. 1] of Integer; // I: Integer;begin SetLength(DoutekiArray, 2); //SetLength // for I := Low(DoutekiArray) to High(DoutekiArray) do DoutekiArray[I] := I; for I := Low(SeitekiArray) to High(SeitekiArray) do SeitekiArray[I] := I; // DoutekiArrayCopy := DoutekiArray; SeitekiArrayCopy := SeitekiArray; //[0] SeitekiArrayCopy[0] := 100; DoutekiArrayCopy[0] := 100; //[0] Show([0]: + DoutekiArray[0].ToString + / [0]:' + DoutekiArrayCopy[0].ToString); Show([0]: + SeitekiArray[0].ToString + / [0]:' + SeitekiArrayCopy[0].ToString);end;

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.#embtwebi_jp

[ ^ ]()@var IPointer: ^Integer; //Integer MyInt: Integer; //Integerbegin MyInt := 100; //Integer100

//@ IPointer := @MyInt; //IntegerInteger

// ^ IPointer^ := 20; // 20 ShowMessage(MyInt.ToString); // 20 end;

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.#embtwebi_jp

SetLength[ + ] Insert, Delete Copyvar di, diCopy: array of Integer; // di begin di := [1, 2, 3]; // di(Index 0~2 1,2,3 di := di + di; //di di 61,2,3,1,2,3) di := di + [4, 5]; //di 2(1,2,3,1,2,3,4,5) Insert([8, 9], di, 3);//diIndex[3]8,9(1,2,3,8,9,1,2,3,4,5) Delete(di, 0, 5); //diIndex[0]5(1,2,3,8,9,1,2,3,4,5) diCopy := Copy(di,low(di),Length(di));//Copy(,,) //diCopy1,2,3,4,5 end;

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.#embtwebi_jp

const constfunction Goukei(const Ai: array of Integer): Integer; //var I : Integer;begin Result := 0; for I := Low(Ai) to High(Ai) do //Low/High Result := Result + Ai[I]; //end;//Goukei([10, Y, 27*I]); //[] (Y,IIntegerGoukei(di); //(di array of Integer

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.#embtwebi_jp

array of const array of const TVerRecTVerRecfunction Goukei(const Args: array of const): Extended; //var I : Integer;begin Result := 0; for I := Low(Args) to High(Args) do //Low/High case Args[I].Vtype of vtInteger: vtChar: //end; TVerRec: http://docwiki.embarcadero.com/Libraries/Berlin/ja/System.TVarRec http://docwiki.embarcadero.com/RADStudio/Berlin/ja/Delphi

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.#embtwebi_jp

typevar

//type = record // 1: ; // 2: ; 3: ; end; //end; //type TMyDate= record //TMyDate Year: Integer; //Year(Integer) Month: Byte; //Month(Byte) Day: Byte; //Day(Byte) end;

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.#embtwebi_jp

.

//var Birthday, ADay : TMyDate; //TMyDate Birthday, Aday//begin Birthday.Year := 1995; //.( Birthday.Month := 2; Birthday.Day := 14;

Aday := BirthDay; // Aday.Year := 2017; ShowMessage(Birthday.Year.ToString); //1995 Aday ShowMessage(Aday.Year.ToString); //2017end;

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.#embtwebi_jp

//type TListMyDate array of TMyDate; //TMyDatevar ListMyDate : TListMyDate; //{typevar ListMyDate: array of TMyDate OK }//(begin SetLength(ListMyDate,3); //SetLength3Index[0]~[2]) ListMyDate[0].Year := 1995; // ListMyDate[0].Month := 2; // ListMyDate[0].Day := 14;end;

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.#embtwebi_jp

function procedure privatepublic public// type //Type = record private //unit private : ; //unit // procedure (); //procedure unit public //unit public // type.implementation Procedure (); //procedure function (): ; //end;

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.#embtwebi_jp

implementation

type TMyDate = record //TMyDate private //unit private Year: Integer; // unit Month: Integer; Day: Integer; myDateTime: TDateTime; procedure SetDatetime; //procedureunit public //unit public // type.implementation procedure SetValue(Y, M, D: Integer); //Procedure function GetValue: TDateTime; //function end;

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.#embtwebi_jp

implementation //implementation {$R *.fmx}procedure TMyDate.SetDatetime; //.()TMyDataSetDateimebegin //Year, Month, Day myDateTime(TDateTime myDateTime := EncodeDate(Year, Month, Day); //end;

procedure TMyDate.SetValue(Y, M, D: Integer);//TMyDateSetValuebegin Year := Y; //SetValue Month := M; // Day := D; SetDatetime; //privateend;

function TMyDate.GetValue: TDateTime; //TMyDateGetValuebegin Result := myDatetime; //myDateTimeend;

procedure TForm1.Button1Click(Sender: TObject); //var MyBirthday: TMyDate; //TMyDataMyBirthdaybegin MyBirthday.SetValue(1995, 2, 14); //. ShowMessage(DateTimeToStr(MyBirthday.GetValue)); // .end;

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.#embtwebi_jp

Variant var V: Variant; // V Str : string; // Strbegin V:=10; //10V V:=Hello; //HelloV V:=12.34; //12.34V

Str := V; //Str12.34 V := V+20; //V 12.34 + 20 32.34 V:= V + Str; //V32.3412.34 44.68 V:= Hello; //VHello V := V + Str; //VHello12.34Hello12.34end;

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.#embtwebi_jp

with

New Despose

http://docwiki.embarcadero.com/RADStudio/Berlin/ja/Delphihttp://docwiki.embarcadero.com/RADStudio/Berlin/ja/Delphihttp://docwiki.embarcadero.com/RADStudio/Berlin/ja/Delphihttp://docwiki.embarcadero.com/RADStudio/Berlin/ja/Delphi

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.#embtwebi_jp

[] []

WebWeb : http://forms.embarcadero.com/starter-tutorial-webinar[] []Delphi / C++Builder Starter

Community embarcadero ( )Web http://community.embarcadero.com/

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.#embtwebi_jp

5

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.#embtwebi_jp

Delphi22717:00

C++

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.#embtwebi_jp

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.

Delphi

GitHub

https://github.com/kazaiso/Starter_Tutorial_season2_20170220

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.#embtwebi_jp

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.#embtwebi_jp

var DoutekiArray, DoutekiArrayCopy: array of Integer; // SeitekiArray, SeitekiArrayCopy: Array [0 .. 1] of Integer; // I: Integer;begin SetLength(DoutekiArray, 2); //SetLength // for I := Low(DoutekiArray) to High(DoutekiArray) do DoutekiArray[I] := I; for I := Low(SeitekiArray) to High(SeitekiArray) do SeitekiArray[I] := I; // DoutekiArrayCopy := DoutekiArray; SeitekiArrayCopy := SeitekiArray; //[0] SeitekiArrayCopy[0] := 100; DoutekiArrayCopy[0] := 100; //[0] Show([0]: + DoutekiArray[0].ToString + / [0]:' + DoutekiArrayCopy[0].ToString); Show([0]: + SeitekiArray[0].ToString + / [0]:' + SeitekiArrayCopy[0].ToString);end;

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.#embtwebi_jp

[ ^ ]()@var IPointer: ^Integer; //Integer MyInt: Integer; //Integerbegin MyInt := 100; //Integer100

//@ IPointer := @MyInt; //IntegerInteger

// ^ IPointer^ := 20; // 20 ShowMessage(MyInt.ToString); // 20 end;

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.#embtwebi_jp

SetLength[ + ] Insert, Delete Copyvar di, diCopy: array of Integer; // di begin di := [1, 2, 3]; // di(Index 0~2 1,2,3 di := di + di; //di di 61,2,3,1,2,3) di := di + [4, 5]; //di 2(1,2,3,1,2,3,4,5) Insert([8, 9], di, 3);//diIndex[3]8,9(1,2,3,8,9,1,2,3,4,5) Delete(di, 0, 5); //diIndex[0]5(1,2,3,8,9,1,2,3,4,5) diCopy := Copy(di,low(di),Length(di));//Copy(,,) //diCopy1,2,3,4,5 end;

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.#embtwebi_jp

array of const array of const TVerRecTVerRecfunction Goukei(const Args: array of const): Extended; //var I : Integer;begin Result := 0; for I := Low(Args) to High(Args) do //Low/High case Args[I].Vtype of vtInteger: vtChar: //end; TVerRec: http://docwiki.embarcadero.com/Libraries/Berlin/ja/System.TVarRec http://docwiki.embarcadero.com/RADStudio/Berlin/ja/Delphi

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.#embtwebi_jp

function procedure privatepublic public// type //Type = record private //unit private : ; //unit // procedure (); //procedure unit public //unit public // type.implementation Procedure (); //procedure function (): ; //end;

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.#embtwebi_jp

implementation

type TMyDate = record //TMyDate private //unit private Year: Integer; // unit Month: Integer; Day: Integer; myDateTime: TDateTime; procedure SetDatetime; //procedureunit public //unit public // type.implementation procedure SetValue(Y, M, D: Integer); //Procedure function GetValue: TDateTime; //function end;

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.#embtwebi_jp

implementation //implementation {$R *.fmx}procedure TMyDate.SetDatetime; //.()TMyDataSetDateimebegin //Year, Month, Day myDateTime(TDateTime myDateTime := EncodeDate(Year, Month, Day); //end;

procedure TMyDate.SetValue(Y, M, D: Integer);//TMyDateSetValuebegin Year := Y; //SetValue Month := M; // Day := D; SetDatetime; //privateend;

function TMyDate.GetValue: TDateTime; //TMyDateGetValuebegin Result := myDatetime; //myDateTimeend;

procedure TForm1.Button1Click(Sender: TObject); //var MyBirthday: TMyDate; //TMyDataMyBirthdaybegin MyBirthday.SetValue(1995, 2, 14); //. ShowMessage(DateTimeToStr(MyBirthday.GetValue)); // .end;

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.#embtwebi_jp

Variant var V: Variant; // V Str : string; // Strbegin V:=10; //10V V:=Hello; //HelloV V:=12.34; //12.34V

Str := V; //Str12.34 V := V+20; //V 12.34 + 20 32.34 V:= V + Str; //V32.3412.34 44.68 V:= Hello; //VHello V := V + Str; //VHello12.34Hello12.34end;

# 2017 Embarcadero Technologies, Inc. All rights reserved. Proprietary and confidential.#embtwebi_jp

Delphi