ããã°ã©ãã³ã°ã®äžçã¯åžžã«å€åããæ°ããæè¡ã次ã ãšçãŸããŠããŸããããããé«ãçç£æ§ãšå ç¢ãªã¢ããªã±ãŒã·ã§ã³éçºãå¯èœã«ããå€å žçãªèšèªãåŠã¶äŸ¡å€ã¯ãä»ã§ãå€ãããŸãããDelphiã¯ãè¿ éãªéçºãšç°¡æœãªæ§æã§ç¥ãããããã°ã©ãã³ã°ç°å¢ã§ãããããžãã¹ã¢ããªã±ãŒã·ã§ã³ã«ç¹ã«åŒ·ã¿ãæã¡ãŸãããã®ã¬ã€ãã§ã¯ãDelphiã®åºæ¬ãããIDEã®äœ¿ãæ¹ãèšèªæ©èœãGUIéçºãããŒã¿ããŒã¹ã®æŽ»çšããããã°æ¹æ³ããããŠå¿çšãã¯ããã¯ãŸã§ãçæéã§å¹ççã«Delphiãç解ããããã®ãšãã»ã³ã¹ãåçž®ããŠçŽ¹ä»ããŸããããžãã¹ããŒãœã³ã®çæ§ãããããDelphiãå§ããããšèããŠããæ¹ã ã«æé©ãªå 容ããããããããæãããªå£èª¿ã§è§£èª¬ããããŸãã
1. Delphi å ¥é – ã¯ãããŠã®10å
1.1 Delphiãšã¯ïŒ – æŠèŠãšæŽå²
Delphiã¯ãé«éãªãã€ãã£ãã¢ããªã±ãŒã·ã§ã³éçºã®ããã«äœ¿ãããããã°ã©ãã³ã°ç°å¢åã³ããã°ã©ãã³ã°èšèªã§ããEmbarcadero Technologiesã«ãã£ãŠéçºãããäž»ã«ãã¹ã¯ããããã¢ãã€ã«ããŸãã¯Webã¢ããªã±ãŒã·ã§ã³ã®æ§ç¯ã«å©çšãããŸãã
Delphiã®æŽå²ã¯1995幎ãŸã§é¡ãããšãã§ããåœæãšããŠã¯ç»æçãªéçºç°å¢ãšããŠæ³šç®ãããŸããããã®åŒ·åãªRADïŒRapid Application DevelopmentïŒæ©èœã«ãããéçºè ã¯çæéã§å¹ççã«ã¢ããªã±ãŒã·ã§ã³ãéçºããããšãå¯èœãšãªããŸããã
ããŒãžã§ã³ã¢ãããéããããšã«ãDelphiã¯ããã«é²åãéããçŸä»£ã®æ§ã ãªOSããã©ãããã©ãŒã ã«é©å¿ããããã«ãªããŸããããã®æ±çšæ§ãšæ¡åŒµæ§ã¯å€ãã®éçºè ã«æ¯æãããŠããŸãã
1.2 Delphiã®ã€ã³ã¹ããŒã«æ¹æ³
Delphiãã€ã³ã¹ããŒã«ããã«ã¯ããŸãEmbarcaderoã®å ¬åŒãŠã§ããµã€ãã蚪ããå©çšãããã©ãããã©ãŒã ã«é©ããã€ã³ã¹ããŒã©ãŒãããŠã³ããŒãããå¿ èŠããããŸããDelphiã®è©Šçšçãå©çšå¯èœã§ãããåå¿è ãæ°è»œã«è©Šãããšãã§ããŸãã
ã€ã³ã¹ããŒã©ãŒãå®è¡åŸãç»é¢ã®æ瀺ã«åŸã£ãŠé²ããŸããå¿ èŠãªã³ã³ããŒãã³ããéžæããå©çšèŠçŽã«åæããåŸãã€ã³ã¹ããŒã«ããã»ã¹ãå§ãŸããŸãããã®ããã»ã¹ã¯æ°åãèŠããããšããããã€ã³ã¿ãŒãããæ¥ç¶ç°å¢ã«ãã£ãŠã¯ããã«æéããããããšããããŸãã
ã€ã³ã¹ããŒã«å®äºåŸãDelphiãèµ·åããŠã©ã€ã»ã³ã¹èªèšŒãå®æœããããšãå¿ããªãããã«ããŸããããããã§Delphiã®ç°å¢ãæŽããéçºãå§ããããšãã§ããŸãã
1.3 Delphi IDEã®åºæ¬çãªäœ¿ãæ¹
Delphiã®IDEïŒçµ±åéçºç°å¢ïŒã¯ãçŽæçãªæäœãå¯èœã§ãããå¹ççãªããã°ã©ãã³ã°äœæ¥ããµããŒãããŸããIDEã¯ã³ãŒããšãã£ã¿ããã©ãŒã ãã¶ã€ããŒããããã¬ãªã©ãéçºã«å¿ èŠãªããŒã«ãäžå åãããŠããŸãã
ãããžã§ã¯ãã®æ°èŠäœæããããã©ãŒã ãžã®ã³ã³ããŒãã³ãã®é 眮ãã³ãŒãã®èšè¿°ããããã°äœæ¥ãŸã§ããã¹ãŠã®éçºãã§ãŒãºãIDEå ã§å®çµããããšãã§ããŸããè±å¯ãªããžã¥ã¢ã«ã³ã³ããŒãã³ããçšæãããŠãããããèŠãç®ã«ãåªããã¢ããªã±ãŒã·ã§ã³ãå¶äœããããšãå¯èœã§ãã
ãŸããIDEã®äŸ¿å©ãªæ©èœãšããŠã¯ã³ãŒãè£å®ããªãã¡ã¯ã¿ãªã³ã°ããŒã«ãããããããã¯éçºã®çç£æ§ãå€§å¹ ã«åäžãããŠãããŸããåããŠå©çšãããæ¹ã¯ããããã®æ©èœã«ã€ããŠãç©æ¥µçã«åŠãã§ãããŸãããã
1.4 ã·ã³ãã«ãªããã°ã©ã ãäœæããã
Delphiã䜿ã£ãããã°ã©ãã³ã°ã®åºç€ãåŠã¶æåã®äžæ©ãšããŠãç°¡åãªãHello, World!ãããã°ã©ã ãäœæããŠã¿ãŸããããIDEãéãããæ°èŠãããžã§ã¯ãããéžæããŠãé©åœãªãã©ãŒã ã¢ããªã±ãŒã·ã§ã³ãäœæããŸãã
ãã©ãŒã äžã«ãã¿ã³ãé 眮ãããã®ãã¿ã³ãæŒãããéã«ãHello, World!ããšè¡šç€ºããã€ãã³ããã³ãã©ãäœããŸããã³ã³ããŒãã³ãã®ã€ãã³ãã«å¯ŸããåŠçãæžãããšã§ãGUIã¢ããªã±ãŒã·ã§ã³ã®åäœãå¶åŸ¡ã§ããŸãã
ããã°ã©ã ãå®æããããããã«ãããŠå®è¡ããŸããããã§ç»é¢ã«ãHello, World!ããšããã¡ãã»ãŒãžã衚瀺ãããã°ãæåã§ãããã®åºæ¬ããã¹ã¿ãŒããããšããå§ããŠãåŸã ã«ããè€éãªããã°ã©ã ãžãšã¹ãããã¢ããããŠãããŸãããã
2. Delphiã®èšèªæ©èœ
2.1 Delphiã®åºæ¬æ§æãšææ³
Delphiã®åºæ¬æ§æã¯ãä»ã®ããã°ã©ãã³ã°èšèªãšå€ãã®å ±éç¹ãæã¡ã€ã€ããç¬èªã®ç¹åŸŽãæããŸããäžè¬çãªããã°ã©ã ã¯ãusesããŒã¯ãŒãã§å©çšãããŠããããèšè¿°ãå§ãŸããbeginãšendããŒã¯ãŒãã«å²ãŸããéšåã§åœä»€ãèšè¿°ããŸãããã®æµããç解ããããšã¯Delphiããã°ã©ãã³ã°ã®åºç€ãåŠã¶äžã§äžå¯æ¬ ã§ãã
ãœãŒã¹ã³ãŒãã¯å€§æåå°æåãåºå¥ãããã»ãã³ãã³ã§åœä»€æãåºåããŸããã³ã¡ã³ãã¯äºçš®é¡ååšããäžè¡ã³ã¡ã³ã㯠// ã§å§ãŸãããããã¯ã³ã¡ã³ã㯠{ } ããã㯠(* *) ã§å²ãããç¯å²ã«èšèŒããŸããããŒã¯ãŒãã®ç解ãšæ£ããæ§æã®æ§ç¯ããDelphiã§ã®ããã°ã©ãã³ã°å¹çãæ Œæ®µã«äžããããšã«ã€ãªãããŸãã
ãŸããããã°ã©ã ã®å¯èªæ§ãé«ããããã«ã¯ãé©åãªã€ã³ãã³ããåœåèŠåãçšããããšãéèŠã§ãããããã¯ææ³ãšã©ãŒãæžããã ãã§ãªããã¡ã³ããã³ã¹ãããŒã ã§ã®äœæ¥ã容æã«ããããã«å¿ èŠãªæ £ç¿ãšãªã£ãŠããŸãã
2.2 å€æ°ãšããŒã¿åã®ç解
Delphiã¯éçåä»ãèšèªã§ãããå€æ°ã䜿çšããéã«ã¯åãæå®ããå¿ èŠããããŸããåºæ¬çãªããŒã¿åã«ã¯ãIntegerãFloatãCharãStringãªã©ãããããããã䜿ã£ãŠæ°å€ãæåãæååãªã©ãæ±ããŸããå€æ°å®£èšã¯varã»ã¯ã·ã§ã³ã§è¡ããåãåŸãã«èšè¿°ããŠå®£èšããŸãã
ã³ã¬ã¯ã·ã§ã³ãè€åããŒã¿åãDelphiã§ã¯ãµããŒããããŠãããé åãã¬ã³ãŒããã¯ã©ã¹ãã€ã³ã¿ãŒãã§ãŒã¹ãšãã£ãåã§ããŒã¿æ§é ãããé«åºŠã«æ±ãããšãã§ããŸããå€æ°ã«é©åãªåãéžã¶ããšã¯ãå®å šãã€å¹ççãªããã°ã©ã ãäœãäžã§ã®éµãšãªããŸãã
åå€æã¯æé»çã«è¡ãããããšãããã°ãæ瀺çã«Castãè¡ãå¿ èŠãããå Žé¢ããããŸããäŸãã°Integeråã®å€æ°ã«Floatåã®å€ãå²ãåœãŠãã«ã¯ãé©åãªãã£ã¹ããäžå¯æ¬ ã§ããåå®å šæ§ãä¿ã€ããã«ããåå€æã®èŠåãæ£ããç解ããŠããããšãèèŠã§ãã
2.3 å¶åŸ¡æ§é ïŒã«ãŒããšæ¡ä»¶åå²
Delphiã§ããã°ã©ã ã®æµããå¶åŸ¡ããã«ã¯ãæ¡ä»¶åå²ãšã«ãŒããšããæ§é ã䜿çšããŸããifæãcaseæãšãã£ãæ¡ä»¶åå²ã¯ããã°ã©ã ã®å®è¡ãæ¡ä»¶ã«å¿ããŠå€æŽããã®ã«å©çšãããwhileæãforæãšãã£ãã«ãŒãã¯ç¹å®ã®æ¡ä»¶ãæºãããããŸã§ç¹°ãè¿ãåŠçãè¡ãããã®ã«äœ¿çšãããŸãã
ifæã¯ç¹å®ã®æ¡ä»¶ãtrueã®æã«ãäžæ¬åŒ§ã§å²ãŸãããããã¯å ã®ã³ãŒããå®è¡ããŸããif-elseæ§é ãçšããããšã§ãæ¡ä»¶ãæºããããªãå Žåã«å®è¡ããã代æ¿ã®åŠçãå®çŸ©ã§ããŸããè€æ°ã®æ¡ä»¶ãå€å®ããã«ã¯ããã¹ããããifæãelse ifæ§æãå©çšããŸãã
äžæ¹ã§ãforæã¯ãããããå®ããããåæ°ã®ã«ãŒãåŠçãè¡ããŸããwhileæãšrepeat-untilæã¯æ¡ä»¶ãfalseã«ãªããŸã§ã«ãŒãåŠçãç¶ãããšããç¹ãå ±éããŠããŸãããwhileã¯ã«ãŒãã®åã«ãrepeat-untilã¯ã«ãŒãã®åŸã«æ¡ä»¶ããã§ãã¯ããŸãããããã®æ§é ãããŸã䜿ãåããããšã§ãå¹ççãã€æå¿«ã«ããã°ã©ã ãå¶åŸ¡ã§ããŸãã
2.4 é¢æ°ãšããã·ãŒãžã£ã®äœæ
Delphiã§ã¯ãã³ãŒãã®åå©çšæ§ãé«ããããã«ãé¢æ°ãããã·ãŒãžã£ãšãã£ããµãã«ãŒãã³ãå®çŸ©ããŸããé¢æ°ã¯å€ãè¿ãã«ãŒãã³ã§ãããããã·ãŒãžã£ã¯å€ãè¿ããªãã«ãŒãã³ã§ããããããé©åã«äœ¿ãåããããšã§ãã³ãŒãã®ã¢ãžã¥ãŒã«æ§ãšå¯èªæ§ãåäžããŸãã
é¢æ°ã®å®£èšã¯functionããŒã¯ãŒãã䜿çšããæ»ãå€ã®åãæå®ããŸããããã·ãŒãžã£ã¯procedureããŒã¯ãŒãã§å§ãŸããã©ã¡ããåŒæ°ãªã¹ããéããŠå€éšããæ å ±ãåãåããŸãããµãã«ãŒãã³å ã®ããŒã«ã«å€æ°ã¯ããã®ãµãã«ãŒãã³ã®å®è¡äžã«ã®ã¿ååšããŸãã
ãµãã«ãŒãã³ã®å°å ¥ã¯ãããã°ã©ã ãè«ççãªãããã¯ã«åå²ããåéšåãæ確ãªè²¬ä»»ãæã€ããšãå¯èœã«ããŸããããã«ãã£ãŠããããã°ãã³ãŒãã¡ã³ããã³ã¹ã容æã«ãªããããŒã ã§ã®éçºã«ãããŠãå¹ççãªååãè¡ããããã«ãªããŸãã
3. ã°ã©ãã£ã«ã«ãŠãŒã¶ãŒã€ã³ã¿ãŒãã§ãŒã¹éçº
Delphiã¯ãã°ã©ãã£ã«ã«ãŠãŒã¶ãŒã€ã³ã¿ãŒãã§ãŒã¹(GUI)ã®éçºã«ãããŠåªããæ©èœãæã€çµ±åéçºç°å¢(IDE)ã§ããç¬èªã®ããžã¥ã¢ã«ã³ã³ããŒãã³ãã©ã€ãã©ãª(VCL)ãå©çšããŠãæŽç·Žããããã¹ã¯ãããã¢ããªã±ãŒã·ã§ã³ã®éçºãå¯èœã«ãªããŸãã
GUIéçºã§ã¯ããŠãŒã¶ãŒãçŽæçã«æäœã§ããç»é¢ã®ãã¶ã€ã³ãéèŠã§ããDelphiã®ãã©ãŒã ãã¶ã€ããŒã䜿çšãããšããã©ãã°ïŒããããã§ã³ã³ããŒãã³ããé 眮ããããããã£ãšãã£ã¿ã§ç°¡åã«èª¿æŽããããšãã§ããŸãã
匷åãªã³ã³ãã€ã©ãšãããã°ããŒã«ãåããåå¿è ããããã®éçºè ãŸã§å¹ åºã察å¿ããŠãããããé«å質ãªã¢ããªã±ãŒã·ã§ã³å¶äœãæ¯æŽããŸãããã®èšäºã§ã¯ããã®äžæ žæ©èœã«çŠç¹ãåœãŠã解説ãå±éããŸãã
3.1 ãã©ãŒã ãã¶ã€ããŒã®æŽ»çš
ãã©ãŒã ãã¶ã€ããŒã¯ãDelphiã§ã®ã¢ããªã±ãŒã·ã§ã³å¶äœã«ãããŠäžå¿ãšãªãããŒã«ã§ããããžã¥ã¢ã«ã³ã³ããŒãã³ãããã©ãŒã äžã«é 眮ããã¢ããªã±ãŒã·ã§ã³ã®éªšæ Œã圢æããŸãã
ã³ã³ããŒãã³ãã®ããããã£ã¯çŽæçã«èšå®ã§ããå®éã®ã¢ããªã±ãŒã·ã§ã³ã®åäœãæš¡ããŠãã¬ãã¥ãŒããæ©èœããããŸããããã«ãããéçºè ã¯ãªã¢ã«ã¿ã€ã ã§ãã¶ã€ã³ã®å€æŽã確èªããä¿®æ£ãå ããããšãã§ããŸãã
ãŸãããã©ãŒã ãã¶ã€ããŒã¯æ¡åŒµæ§ã«å¯ãã§ããããµãŒãããŒãã£è£œã®ã³ã³ããŒãã³ããçµã¿èŸŒãããšãã§ããŸããããã«ãããéçºè ã®åµé åãšå¹çåãä¿é²ããŸãã
3.2 ã³ã³ãããŒã«ã®é 眮ãšã«ã¹ã¿ãã€ãº
Delphiã§GUIãäœæããéã«ã¯ãã³ã³ãããŒã«ã®é 眮ãšã«ã¹ã¿ãã€ãºãéåžžã«éèŠã§ããã³ã³ãããŒã«ã¯ãã¿ã³ãã©ãã«ããšãã£ããããã¯ã¹ãšãã£ãGUIèŠçŽ ã§ããããŠãŒã¶ãŒã®å ¥åãšã¢ããªã±ãŒã·ã§ã³ã®å¿çã®äžå¿ãæ ããŸãã
é 眮ããã³ã³ãããŒã«ã¯ããµã€ãºãè²ããã©ã³ããªã©è±å¯ãªããããã£ãæã£ãŠããããããé©åã«èª¿æŽããããšã§ãŠãŒã¶ãŒãšã¯ã¹ããªãšã³ã¹ãåäžãããããšãã§ããŸããDelphiã®ããããã£ãšãã£ã¿ã䜿çšããŠããããã®è©³çŽ°ãªèšå®ãè¡ããŸãã
ã«ã¹ã¿ãã€ãºæ§ã¯ãDelphiãGUIéçºã®ããã«åŠäœã«åŒ·åãªããŒã«ãã瀺ã蚌ãã§ããå©çšè ã®ããŒãºã«å¿ããŠã现ããã³ã³ãããŒã«ã調æŽããããšã§ãããããã«æé©ãªã€ã³ã¿ãŒãã§ãŒã¹ãæ§ç¯ã§ããŸãã
3.3 ã€ãã³ãé§åããã°ã©ãã³ã°ã®åºæ¬
ã€ãã³ãé§åããã°ã©ãã³ã°ã¯ããŠãŒã¶ãŒããã®ã¢ã¯ã·ã§ã³ã«åå¿ããŠãã¢ããªã±ãŒã·ã§ã³ãç¹å®ã®åŠçãè¡ãããã°ã©ãã³ã°ãã©ãã€ã ã§ããDelphiã§ã®éçºã¯ãã®æŠå¿µã«åºã¥ããŠããŸãã
ããšãã°ããã¿ã³ãã¯ãªãã¯ããããšããã€ãã³ãã¯ãé¢é£ä»ããããã€ãã³ããã³ãã©å ã®ã³ãŒããå®è¡ããããªã¬ãŒãšãªããŸããããã«ãããã³ãŒããã€ãã³ãããšã«æŽçãã管çãããããªããŸãã
Delphiã§ã¯ãå€æ§ãªçµã¿èŸŒã¿ã€ãã³ãã®ã»ããã«ã¹ã¿ã ã€ãã³ããå®çŸ©ããŠãããè€éãªãŠãŒã¶ãŒã€ã³ã¿ã©ã¯ã·ã§ã³ã«å¯Ÿå¿ããããšãå¯èœã§ããããã«ããéçºè ã¯ãã¢ããªã±ãŒã·ã§ã³ã®ããžãã¯ãå¹æçã«æ§ç¯ã§ããŸãã
3.4 ã¢ããªã±ãŒã·ã§ã³ã®å€èŠ³ãšã¹ã¿ã€ã«
Delphiã§ã¯ãã¢ããªã±ãŒã·ã§ã³ã®å€èŠ³ãšã¹ã¿ã€ã«ã现ããå¶åŸ¡ã§ããŸããããŸããŸãªããžã¥ã¢ã«ããŒããé©çšããããèªåã§ããŒããäœæããŠã¢ããªã±ãŒã·ã§ã³ã®ãã©ã³ãã£ã³ã°ã匷åããããšãå¯èœã§ãã
ã¹ã¿ã€ãªã³ã°æ©èœã«ãã£ãŠãã³ã³ãããŒã«ã®å€èŠãäžè²«ããŠèª¿æŽããããç¹å®ã®ãã©ãŒã ãã¢ããªã±ãŒã·ã§ã³å šäœã§ç¬èªã®ãã¶ã€ã³èšèªã確ç«ã§ããŸãããŠãŒã¶ãŒã«ãšã£ãŠèŠèŠçé åã¯ãã¢ããªã±ãŒã·ã§ã³ã®äœ¿ãåæã«å€§ããå¯äžããŸãã
ãŸãããã¶ã€ã³ãã¿ãŒã³ããŠãŒã¶ãŒã€ã³ã¿ãŒãã§ãŒã¹ã¬ã€ãã©ã€ã³ã«åŸã£ãŠã¹ã¿ã€ã«ãæŽããããšã§ã䜿ããããç解ããããã¢ããªã±ãŒã·ã§ã³ãäœãäžããããšãã§ããŸããDelphiã¯ãããããããŒãºã«å¿ããããã®å¹ åºããªãã·ã§ã³ãæäŸããŸãã
4. ããŒã¿ããŒã¹ãšãã«ãã¡ã€
ããŒã¿ããŒã¹ç®¡çã¯ä»»æã®ãœãããŠã§ã¢éçºã«ãããŠéèŠãªåœ¹å²ãå ããŠããŸããDelphiç°å¢ã§ããŒã¿ããŒã¹ãšã®ããåããè¡ãéã«ã¯ããã®æ¥ç¶æ¹æ³ãšããŒã¿ã®æ±ãæ¹ãçç¥ããŠããããšãäžå¯æ¬ ã§ãã
Delphiã¯ããã¬ãã·ãã«ã«ããŒã¿ããŒã¹ãæäœã§ããããŒã«ãå€æ°åããŠãããããŸããŸãªããŒã¿ããŒã¹ã·ã¹ãã ãšã®äºææ§ãæã£ãŠããŸããããã«ãããéçºè ã¯ããŒã¿é§ååã®ã¢ããªã±ãŒã·ã§ã³ã容æã«äœæã§ããŸãã
ãã®ç« ã§ã¯ããã«ãã¡ã€ãçšããããŒã¿ããŒã¹ã®æ¥ç¶ãSQLã®å®è¡ãå®è·µçãªã¢ããªã±ãŒã·ã§ã³ã®äœææ¹æ³ãããã³ããã©ãŒãã³ã¹æ¹åã®ããã®ãã¹ããã©ã¯ãã£ã¹ã«ã€ããŠè©³ãã解説ããŸãã
4.1 ããŒã¿ããŒã¹æ¥ç¶ã®åºç€
Delphiã§ããŒã¿ããŒã¹ã«æ¥ç¶ããããã®æåã®ã¹ãããã¯ãé©åãªããŒã¿ããŒã¹æ¥ç¶ã³ã³ããŒãã³ãã®éžæã§ããäžè¬ã«TDatabaseãTSQLConnectionãTFDConnectionãªã©ãå©çšãããŸãã
æ¥ç¶ã³ã³ããŒãã³ãã¯ãããŒã¿ããŒã¹ã®çš®é¡ãã¢ã¯ã»ã¹ããããã®ãã©ã€ãããµãŒããŒã®äœçœ®ãèªèšŒæ å ±ãªã©ãèšå®ããããã«çšããŸããã³ã³ããŒãã³ãã®ããããã£ãé©åã«èšå®ããããšã§ãå®å šãã€å¹ççãªããŒã¿ããŒã¹æ¥ç¶ãå¯èœãšãªããŸãã
ãŸãããã¶ã€ããŒã䜿ãããšã§ããžã¥ã¢ã«çã«æ¥ç¶ãèšå®ã§ããã³ãŒãã£ã³ã°ã«ãããã¹ãæžããããšãã§ããŸããããã¯éçºããã»ã¹ãå éããããã確å®ãªã¢ããªã±ãŒã·ã§ã³éçºãå©ããããšã«ãªããŸãã
4.2 SQLã¯ãšãªã®å®è¡ãšããŒã¿æäœ
ããŒã¿ããŒã¹ãžã®æ¥ç¶ã確ç«ãããã次ã«SQLã¯ãšãªã䜿ã£ãŠããŒã¿ãæäœããããšãã§ããŸããDelphiã§ã¯ãTQueryãTSQLQueryãTFDQueryãªã©ã®ã³ã³ããŒãã³ãããã®ç®çã§äœ¿çšãããŸãã
ãããã®ã³ã³ããŒãã³ãã䜿çšããããšã§ãSELECTãINSERTãUPDATEãDELETEãªã©ã®SQLæãå®è¡ããããŒã¿ããŒã¹å ã®ããŒã¿ãèªã¿æžãããããšãã§ããŸããããããã£ãšã€ãã³ããããŸã掻çšããããšã§ãè€éãªããŒã¿æäœãç°¡æœãªã³ãŒãã«èœãšã蟌ãããšãå¯èœã§ãã
ããŒã¿æäœã®éã«ã¯ãSQLã€ã³ãžã§ã¯ã·ã§ã³æ»æãªã©ã®ã»ãã¥ãªãã£ãªã¹ã¯ã«æ³šæãããã©ã¡ãŒã¿åãããã¯ãšãªãå©çšããããšãæšå¥šãããŸããããã«ãããã¢ããªã±ãŒã·ã§ã³ã®å®å šæ§ãåäžããŸãã
4.3 ããŒã¿ããŒã¹ã䜿ã£ãã¢ããªã±ãŒã·ã§ã³äŸ
Delphiã䜿çšããããŒã¿ããŒã¹ã¢ããªã±ãŒã·ã§ã³ã®äŸãšããŠã¯ã顧客管çã·ã¹ãã ãåšåº«ç®¡çã·ã¹ãã ãäºçŽã·ã¹ãã ãªã©ãæããããŸãããããã®ã·ã¹ãã ã¯ãããŒã¿ã®ä¿åãæ€çŽ¢ãæŽæ°ãšãã£ãåºæ¬çãªããŒã¿ããŒã¹æäœã«äŸåããŠããŸãã
ããŒã¿ã¢ãŠã§ã¢ã³ã³ããŒãã³ãã䜿çšããã°ãDBGridãDBEditãªã©ã®UIèŠçŽ ãããŒã¿ããŒã¹ãšçŽæ¥çµã³ã€ããããšãã§ããããããŠãŒã¶ãŒã€ã³ã¿ãŒãã§ã€ã¹ã®éçºã容æã«ãªããŸãã
ãããã®ã¢ããªã±ãŒã·ã§ã³ã¯ãªã¢ã«ã¿ã€ã ã§ããŒã¿æäœãè¡ãããã®åªããã€ã³ã¿ã©ã¯ãã£ããã£ããŠãŒã¶ãŒã«æäŸããããžãã¹ã®å¹çåã«å€§ããè²¢ç®ããããšãã§ããŸãã
4.4 ãã¹ããã©ã¯ãã£ã¹ãšæ§èœã®ãã³ã
Delphiã§å¹ççãªããŒã¿ããŒã¹ã¢ããªã±ãŒã·ã§ã³ãéçºããããã«ã¯ãã³ãŒãã®æé©åãéµãšãªããŸããäŸãã°ãå¿ èŠã®ãªãããŒã¿ããŒã¹æ¥ç¶ãéãããŸãŸã«ããªãã䜿ããªããªã£ããªãœãŒã¹ã¯éããã«è§£æŸããããªã©ãæããããŸãã
ãŸãã倧éã®ããŒã¿ãåŠçããéã¯ãã¯ãšãªã®æé©åãé©åãªã€ã³ããã¯ã¹ã®äœ¿çšããããåŠçã®å®è£ ãªã©ã«ãã£ãŠããã©ãŒãã³ã¹ãå€§å¹ ã«åäžãããããšãå¯èœã§ãããããã®ã¢ãããŒãã¯ãå¿çæ§ã®é«ãã¢ããªã±ãŒã·ã§ã³ãäœæããããã«æ¬ ãããŸããã
æåŸã«ããããã°ãšãããã¡ã€ãªã³ã°ããŒã«ã䜿çšããŠãããã©ãŒãã³ã¹ããã«ããã¯ãç¹å®ããã³ãŒãã®æ¹åãè¡ãããšããé«æ§èœãªããŒã¿ããŒã¹ã¢ããªã±ãŒã·ã§ã³ãéçºããããã®éèŠãªã¹ãããã§ãã
5. ãããã°ãšãšã©ãŒåŠç
5.1 ãããã°ããŒã«ã®æŠèŠãšå©çšæ¹æ³
Delphiã«ã¯åªãããããã°ããŒã«ãåãã£ãŠãããéçºã倧ãã«å©ããŠãããŸããIntegrated Development Environment (IDE) ã«ã¯ãã¬ã€ã¯ãã€ã³ãã®èšå®ãã¹ãããå®è¡ãå€æ°ç£èŠãªã©ã®ãããã°æ©èœãå«ãŸããŠããŸãããããã®ããŒã«ãå©çšããããšã§ãã³ãŒãã®åè¡ãã©ã®ããã«å®è¡ãããããææ¡ããè€éãªãšã©ãŒã®èª¿æ»ã容æã«è¡ããŸãã
ãã¬ã€ã¯ãã€ã³ããèšå®ããã«ã¯ãã³ãŒãå ã®ä»»æã®è¡ã§ããŠã¹ãã¯ãªãã¯ããF5ããŒãæŒãããšã§ããã°ã©ã ãå®è¡ããŸããå®è¡ããã¬ã€ã¯ãã€ã³ãã§åæ¢ãããšãéçºè ã¯çŸåšã®å€æ°ã®å€ãã³ãŒã«ã¹ã¿ãã¯ãæ€æ»ããããšãã§ããŸãããã®æ å ±ãçšããŠåé¡ãç¹å®ããä¿®æ£ã®æ¹åæ§ãå°ãåºããŸãã
ãŸãIDEã®ãŠã©ãããªã¹ããããŒã«ã«å€æ°ãŠã£ã³ããŠãå©çšããããšã§ãããã°ã©ã ã®å®è¡äžã«å€æ°ã®å€ãã©ã®ããã«å€é·ããŠãããã芳å¯ã§ããŸãããã®ãããªæ©èœãå©çšããŠå¹ççã«ããã°ã©ã ããããã°ããäžå ·åã®ç¹å®ã«åœ¹ç«ãŠãŸãããã
5.2 ãšã©ãŒã¡ãã»ãŒãžã®è§£èªãšãšã©ãŒåŠç
Delphiã§ããã°ã©ã ãéçºããŠãããšãããŸããŸãªãšã©ãŒã¡ãã»ãŒãžã«ééããŸãããããã®ã¡ãã»ãŒãžãé©åã«è§£èªããé©åãªå¯ŸåŠãè¡ãããšãéèŠã§ãããšã©ãŒã¡ãã»ãŒãžã«ã¯ãçºçãããšã©ãŒã®ã¿ã€ãããšã©ãŒãçºçããè¡çªå·ããããŠåé¡è§£æ±ºãžã®ãã³ããå«ãŸããŠããããšãå€ãã§ãã
äŸãã°ãAccess violationãã¯ãæªå²ãåœãŠã®ã¡ã¢ãªã«ã¢ã¯ã»ã¹ããããšããéã«çºçãããšã©ãŒã§ããããã«å¯ŸåŠããã«ã¯ããã€ã³ã¿ãé©åã«åæåãããŠããããç¯å²å€ã®ã¡ã¢ãªã«ã¢ã¯ã»ã¹ããŠããªããã確èªããããšãæ±ããããŸãããšã©ãŒã¡ãã»ãŒãžããåŸãããæ å ±ãããšã«ãã·ã¹ãããã£ãã¯ã«ãããã°ãè¡ããŸãããã
ãŸããäŸå€åŠçæ©æ§ã掻çšããããšã§ããã°ã©ã ã®ã¬ãžãªãšã³ã¹ãåäžãããããšãã§ããŸããtry…exceptãããã¯ã䜿ã£ãŠãäºæãã¬ãšã©ãŒããããã°ã©ã ãä¿è·ããé©åãªãšã©ãŒãã³ããªã³ã°ãå®æœããããšãéèŠã§ãã
5.3 å¹ççãªãããã°ãã¯ããã¯
ãããã°ãè¡ãéã«ã¯ãåã«ã³ãŒããå®è¡ããŠãšã©ãŒãèŠã€ããã ãã§ãªããå¹ççãªãã¯ããã¯ãçšããããšãéèŠã§ããäžã€ã®ãã¯ããã¯ã¯ããé€å€æ³ãã䜿ãããšã§ãã倧ããªãããžã§ã¯ãã®å Žåãã©ã®éšåãåé¡ãåŒãèµ·ãããŠããããçµã蟌ãããã«ãã³ãŒãã®ã»ã¯ã·ã§ã³ãã³ã¡ã³ãã¢ãŠãããŠæœåšçãªåé¡ç¹ãç¹å®ããŸãã
ãŸããã³ãŒãã®æ©ã段éã§ãã°åºåãåãå ¥ããããšãæå¹ã§ãããã°ãéããŠå®è¡ãããŒã远跡ãããšã©ãŒãçºçããçŽåã®åäœãç¥ãããšãã§ãããããåé¡ã®åå ãèŠã€ãããããªããŸããDelphiã®Event Logãå€éšã®ãã°è§£æããŒã«ãçšããããšãæšå¥šããŸãã
ããã«ããŠããããã¹ããå°å ¥ãããšãç¹å®ã®ã³ã³ããŒãã³ããæåŸ éãã®åäœãããŠããããéé¢ããŠæ€èšŒã§ããããã倧èŠæš¡ãªã¢ããªã±ãŒã·ã§ã³ã§ããããã°ã容æã«ããŸããã©ã®ãããªå€æŽãå ããåŸããã¹ããç¹°ãè¿ãããšã§ãæ°ããªãšã©ãŒã®å°å ¥ãé²ãããšãã§ããŸãã
5.4 å®è·µçãªãšã©ãŒè§£æ±ºäºäŸ
å®è·µçãªãšã©ãŒè§£æ±ºäºäŸãšããŠãã¡ã¢ãªãªãŒã¯ã®ç¹å®ãšè§£æ±ºãæããããŸããDelphiã«ã¯ã¡ã¢ãªãªãŒã¯ãç¹å®ããããã®ããŒã«ãæšæºã§æèŒãããŠããå ŽåããããŸãããããã®ããŒã«ã䜿çšããŠã³ãŒãããããã¡ã€ãªã³ã°ããå²ãåœãŠããããªããžã§ã¯ããé©åã«è§£æŸãããŠãããã確èªããããšãã§ããŸãã
å¥ã®äºäŸãšããŠããããããã¯ã®è§£æ¶ããããŸããè€æ°ã®ã¹ã¬ãããåæã«åããªãœãŒã¹ãã¢ã¯ã»ã¹ããããšããŠãæ°žä¹ ã«åŸ æ©ç¶æ ã«é¥ãããšããããŸãããã®ãããªåé¡ã«å¯ŸåŠããããã«ã¯ãããã¯æ©æ§ã®èšèšãèŠçŽããã¹ã¬ããéã§ãªãœãŒã¹ãå®å šã«ã¢ã¯ã»ã¹ãããããã«å·¥å€«ããå¿ èŠããããŸãã
ã¡ã¢ãªãªãŒã¯ããããããã¯ã®ãããªè€éãªåé¡ã»ã©ããããã°ã®éã«ã¯è©³çŽ°ãã€æ éãªã¢ãããŒããæ±ããããŸããããããå ·äœçãªè§£æ±ºçãåèã«ããªããããããšããæã«åããŠããããšãããããã°ã®ã¹ãã«ã磚ãäžã§å€§åã§ãã
6. å¿çšãã¯ããã¯ãšã©ã€ãã©ãª
Delphiã䜿çšããäžã§ããã ã³ãŒããèšè¿°ããã ãã§ãªããè±å¯ãªã©ã€ãã©ãªãã³ã³ããŒãã³ãã掻çšããããšãçŸä»£ã®ã¢ããªã±ãŒã·ã§ã³éçºã§ã¯èŠæ±ãããŸããå¿çšãã¯ããã¯ãšã©ã€ãã©ãªãé§äœ¿ããããšã§ãéçºå¹çãå€§å¹ ã«åäžãããããšãå¯èœã§ãã
Delphiã®ã©ã€ãã©ãªã¯éåžžã«å€å²ã«æž¡ããã°ã©ãã£ã«ã«ãŠãŒã¶ãŒã€ã³ã¿ãŒãã§ãŒã¹(GUI)ã®åŒ·åããããŒã¿ããŒã¹æäœããã«ãã¡ãã£ã¢ã®åŠçãŸã§å¹ åºãç¯å²ãã«ããŒããŠããŸãããŸããã³ãã¥ããã£ã«ãããªãŒãã³ãœãŒã¹ã©ã€ãã©ãªãæ°å€ãååšããåã ã®ãããžã§ã¯ãã«åãããŠå¿ èŠãªæ©èœãæ¢ãããšãã§ããŸãã
ã³ã³ããŒãã³ãæåéçºã«ãããŠã¯ãæ¢åã®ã³ã³ããŒãã³ãã掻çšããŠè¿ éã«ã¢ããªã±ãŒã·ã§ã³ãçµã¿ç«ãŠãããšãå¯èœã§ãããããã®ã³ã³ããŒãã³ãã¯ãåå©çšæ§ãšã«ã¹ã¿ãã€ãºæ§ãæã¡åãããŠãããã©ã®ãããªãããžã§ã¯ãã«ãæè»ã«å¯Ÿå¿ããããšãã§ããŸãã
6.1 Delphiã©ã€ãã©ãªãšã³ã³ããŒãã³ãã®æŽ»çš
Delphiã©ã€ãã©ãªãšã³ã³ããŒãã³ãã®æŽ»çšã¯ãå質ã®é«ãã¢ããªã±ãŒã·ã§ã³ãçŽ æ©ãéçºããããã®éµã§ãããããã¯ããã°ã©ãã³ã°ã®åŽåãåæžããããè€éãªæ©èœãç°¡åã«çµã¿èŸŒãããšãå¯èœã«ããŸãã
VCL(Visual Component Library)ãFireMonkey(FMX)ãªã©ã®èŠèŠçã³ã³ããŒãã³ãã¯ããŠãŒã¶ã€ã³ã¿ãŒãã§ãŒã¹ã®äœæãçŽæçã«è¡ãããšãã§ããŸãããããã®ã©ã€ãã©ãªã«ã¯ãæ§ã ãªãŠãŒã¶ãŒãšã¯ã¹ããªãšã³ã¹ãæäŸããããã«ã«ã¹ã¿ãã€ãºå¯èœãªãŠã£ãžã§ãããã³ã³ãããŒã«ãå«ãŸããŠããŸãã
ããã«ãããŒã¿ã¢ã¯ã»ã¹ã³ã³ããŒãã³ãã䜿çšããã°ãç°ãªãããŒã¿ãœãŒã¹ãããŒã¿åœ¢åŒãšã®æ¥ç¶ãç°¡åã«ãªããŸããããããéããŠãSQLããŒã¿ããŒã¹ãªã©ãžã®ã¢ã¯ã»ã¹ããRESTful APIã®å©çšãªã©ãã¹ã ãŒãºã«è¡ããããã«ãªããŸãã
6.2 ãã«ãã¹ã¬ãããšäžŠè¡åŠç
ãã«ãã¹ã¬ããããã°ã©ãã³ã°ã¯ãã¢ããªã±ãŒã·ã§ã³ã®ããã©ãŒãã³ã¹ãåäžãããéèŠãªæ¹æ³ã®äžã€ã§ããDelphiã§ã¯ãç°¡åã«ãã«ãã¹ã¬ãããå®è£ ãããªãœãŒã¹ãå¹æçã«æŽ»çšããããšãã§ããŸãã
䞊è¡åŠçãè¡ãããšã§ãã¢ããªã±ãŒã·ã§ã³ã¯è€æ°ã®ã¿ã¹ã¯ãåæã«å®è¡ããèœåãæã¡ãŸãããªãã¬ãŒãã£ã³ã°ã·ã¹ãã ã®ã¹ã±ãžã¥ãŒã©ããããã®ã¹ã¬ããã管çãããã«ãã³ã¢ããã»ããµã®èœåãæ倧éã«å©çšããããã«åŠçãåé ããŸãã
Delphiã§ã¯ãTThreadã¯ã©ã¹ããã«ãã¹ã¬ããããã°ã©ãã³ã°ã®åºç€ãæäŸããŠããŸããããã«ããå®å šãªã¹ã¬ããã®äœæãå®è¡ãåæãå¯èœã§ãããã¢ããªã±ãŒã·ã§ã³ã®å¿çæ§ãšã¹ã±ãŒã©ããªãã£ãå€§å¹ ã«åäžãããããšãã§ããŸãã
6.3 ãããã¯ãŒã¯ããã°ã©ãã³ã°ã®åºæ¬
ãããã¯ãŒã¯ããã°ã©ãã³ã°ã¯ããªã¢ãŒããµãŒããŒãšã®ããŒã¿éä¿¡ãã€ã³ã¿ãŒãããã«æ¥ç¶ããã¢ããªã±ãŒã·ã§ã³ãäœæããããã«äžå¯æ¬ ã§ããDelphiã¯åŒ·åãªãããã¯ãŒã¯æ©èœãæäŸããŠãããã¯ã©ã€ã¢ã³ããšãµãŒããŒéã®éä¿¡ã容æã«å®çŸããŸãã
ã€ã³ã¿ãŒããããããã³ã«ã«åºã¥ãã³ãã¥ãã±ãŒã·ã§ã³ã¯ãIndyãªã©ã®ã³ã³ããŒãã³ããéããŠç°¡åã«æ±ãããšãã§ããŸããããããå©çšããŠHTTPãFTPãSMTPãPOP3ãªã©ã®ãããã³ã«ãæäœããããšã«ãããããŸããŸãªãããã¯ãŒã¯ããŒã¹ã®æ©èœãçµã¿èŸŒãããšãå¯èœã§ãã
TCP/IPãœã±ããããã°ã©ãã³ã°ã§ã¯ãããäœã¬ãã«ã®ãããã¯ãŒã¯æäœãå¯èœã§ãããããçšããŠãã«ã¹ã¿ã ãããã³ã«ãç¹æ®ãªéä¿¡èŠä»¶ã«å¯Ÿå¿ããã¢ããªã±ãŒã·ã§ã³ãäœæããããšãã§ããŸãã
6.4 å€éšã©ã€ãã©ãªãAPIã®çµ±å
ã¢ãã³ãªãœãããŠã§ã¢éçºã§ã¯ãå€éšã®ãªãœãŒã¹ããµãŒãã¹ãå©çšããããšãäžè¬çã§ããDelphiã§ã¯ãå€æ§ãªå€éšã©ã€ãã©ãªãAPIãçµ±åããã¢ããªã±ãŒã·ã§ã³ã«æ¡åŒµæ§ãšæè»æ§ãããããããšãã§ããŸãã
å€éšã©ã€ãã©ãªã®å©çšã¯ãDLLã®ã€ã³ããŒãããå§ãŸããã€ã³ã¿ãŒãã§ãŒã¹ã®å®çŸ©ãããŒã¿æ§é ã®ãããã³ã°ãªã©ã«ãã£ãŠèšèªéã®é£æºãå®çŸããŸãããã®ããã»ã¹ãéããŠãäŸãã°Cèšèªã§æžãããã©ã€ãã©ãªãDelphiã®ã¢ããªã±ãŒã·ã§ã³å ã§äœ¿çšããããšãå¯èœã«ãªããŸãã
APIã®çµ±åã«ã¯ãWebãµãŒãã¹ã®æ¥ç¶ãããœãŒã·ã£ã«ã¡ãã£ã¢ãã©ãããã©ãŒã ãã¯ã©ãŠããµãŒãã¹ã®å©çšãå«ãŸããŸããRESTãSOAPãªã©ã®Web APIã掻çšããããšã§ãDelphiã¢ããªã±ãŒã·ã§ã³ãããå¹ åºããµãŒãã¹ãããŒã¿ã«æ¥ç¶ããããšãã§ããããã«ãªããŸãã
7. ãŸãšã
Delphiã10åã§åŠã¶ããšã¯ããžãã¹ããŒãœã³ã®å¹ççãªã¹ãã«ã¢ãããžã®è¿éã§ããæ¬èšäºã§ã¯ãDelphiå ¥éããäžçŽæè¡ãŸã§ãæŠèª¬ããŸãããDelphiã¯åŒ·åãªWindowsã¢ããªã±ãŒã·ã§ã³éçºããŒã«ã§ãããç¥ã£ãŠããã¹ãèšèªæ©èœãGUIéçºãããŒã¿ããŒã¹æäœããããã°æ¹æ³ããããŠå¿çšãã¯ããã¯ãŸã§ã玹ä»ããŠããŸããæããããç°¡æœã«ããããŠå®è·µçãªå 容ãéçŽãDelphiã®ã€ã³ã¹ããŒã«ããã·ã³ãã«ãªããã°ã©ã äœæããšã©ãŒåŠçãã©ã€ãã©ãªã®æŽ»çšæ³ãŸã§ãåå¿è ã§ãããã«äœ¿ããç¥èã10åã§ç¿åŸã§ããŸããããããDelphiãå§ããå šãŠã®ããžãã¹ããŒãœã³ã«å¿ èŠãªæ å ±ãããã«ãããŸãã