第二章 基本語法
DESCRIPTION
第二章 基本語法. 本章將介紹一些程式語言的基本語法,例如識別字的命名、資料型態、運算子及運算式等 。 2-1 識別字 2-2 資料型態 2-3 運算子 2-4 敘述與運算式. 2- 1 識別字. 本單元介紹什麼是保留字、管制字及識別字。. 保留字 (Keywords). 保留字是任一程式語言已事先賦予某一字串一個特別意義,所以程式設計者不得再重複賦予不同的用途。 例如 if 已被賦予決策敘述,程式設計者當然不得再定義 if 為另外的用途,以下是 Delphi 的保留字。 anddowntoinorstring - PowerPoint PPT PresentationTRANSCRIPT
-
2-1 2-2 2-3 2-4
-
2-1
-
(Keywords) if if Delphi
anddowntoinorstringarrayelseinheritedoutthenasendinitializationpackedthreadvarasmexceptinlineproceduretobeginexportsinterfaceprogramtrycasefileispropertytypeclassfinalizationlabelraiseunitconstfinallylibraryrecorduntilconstructorformodrepeatusesdestructorfunctionnilresourcestringvardispinterfacegotonotsetwhiledivifobjectshlwithdoimplementationofshrxor
-
Directives Delphi
absolutedynamicmessageprivateresidentabstractexportnameprotectedsafecallassemblerexternalnearpublicstdcallautomatedfarnodefaultpublishedstoredcdeclforwardoverloadreadvarargscontainsimplementsoverride readonlyvirtualdefaultindexpackageregisterwritedeprecatedlibrarypascalreintroducewriteonlydispidlocalplatformrequires
-
(Identifier)(Package)Dephi
-
1.AZ_aablOut
ediIn-bb7eleven//+c//+=c//=2.a8bb255b2c3Age#3//c+3//c 3//
-
3.Delphi255
4.ScorescoreSCORE
5.iffor
6.StudentNumber AverageIncomexiak23erp
7.(_)StudentNumberStudent_NumberStu_Numstu_numStuNumstunumStuNum
-
2-2Delphi
-
Delphi 25$$1218
-
Ee100.00232.3E2.3e-3
-
TrueFalse
-
'a'//'Office XP'//Line1Line2'Line1'1310'Line2'
-
DelphiDelphi
-
DelphiSimpleStringStructuredPointerProceduralVariantsimpleordinalintegercharacterBooleanenumeratedsubrangerealstringstructured setarrayrecordfileclassclass referenceinterfacepointerproceduralvariant
-
SimpleSimpleSimpleOrdinalRealOrdinalIntegerCharacterBooleanEnumeratedSubrangeOrdinalOrdinal7-4
-
SubrangeSubrangeSubrangeTnumberTnumberRealInteger type Tnumber = 0..100;
-
RealDelphiReal*GenericFundamental
-
Real5.0*10-324..1.7*1030815~168 Bytes Real482.9*10-39..1.7*103811~126 BytesSingle1.5*10-45..3.4*10387~84 BytesDouble5.0*10-324..1.7*1030815~168 BytesExtended3.6*10-4951...1.1*10493219~2010 BytesComp-263+1..263-119~208 BytesCurency-922337203685477.5808..922337203685477.580719~208 Bytes
-
BooleanTrueFalseBooleanDelphi*
-
Enumerated Enumerated type12-3TmouseButton12-3a type TmouseButton = mbLeft, mbRight, mbMiddle;TmyColor type TmyColor =Red, Yellow, Green, White;
-
IntegerInteger*GenericFundamental
-
Ineger-2147483648~2147483647Signed 32 bisCardinal0~4294967295Unsigned 32 bisShorin-128~127Signed 8 bisSmallin-32768~32767Signed 16 bisLongin-2147483648~2147483647Signed 32 bisIn64-263~263-1Signed 64 biBye0~255Unsigned 8 biWord0~65535Unsigned 16 biLongWord0~4294967295Unsigned 32 bi
-
CharacerCharacer*GenericFundamenal
Char8 bisAnsiChar8 bisWideChar16 bis
-
SringDelphiSring*SringShorSringAnsiSring
-
varBasic student :=studend+1suden var suden : ineger ;sudendsudend
-
Delphivar 1[,2] : ;var i : Ineger ; j,k : Real ; a : Sring ; var i : Ineger = 10 ; a : Sring = 'Office XP';
-
ypecas := ;c1a2 c1 :='a'; a2 :=Inegerc1;INrunc7-1
-
Ineral153.14159Symbolic
conscons PI=3.141593.14159PI
-
const Rae 0.02Rae0.02varDelphiconst = M=3const M = 3
-
2-2bcons
-
sunum=15sunum=20
-
2-2c :1. abab2. FormCreaebcdFormCreaeabcd4bbb3. bnSarClickcabcabccFormCreaec
-
2-3OperaorOperandAssignmenArihmeicComparisonLogicalBiwiseSringUnaryBinary
AssociaiviyPrecedence
-
:= C++JavaVB =sum := a+b; a+bsum sum := 0a := 3b := 5; sum := a + b;08 8 := x ;8x x := 8 ;
-
(Arihmeic operaors)( - )( + )( + )( - )( * )( / )(div)(mod)
-
(Relaional operaors)rueFalseDelphi
=SimpleClassClass ReferenceInerfaceSringPacked SringBooleanX=3>SimpleClassClass ReferenceInerfaceSringPacked SringBooleanXYSimpleSringPacked SringPCharBooleanXSimpleSringPacked SringPCharBooleanY>2=SimpleSringPacked SringPCharBooleanX=SimpleSringPacked SringPCharBooleanY>=3
-
(Logical operaors)Delphi
noBooleanBoolean nox>3andAndBooleanBooleanx>3andy>2orOrBooleanBooleanx>3ory>2xorXORBooleanBooleanx>3xory>2
- Sring operaor =>=
-
Delphishlshr
@, no1*, /, div, mod, and, shl, shr, as2+, -, or, xor3=, , , =, in, is4:=5
-
x+y*zx+y*zx>2 and y>3Delphix>2 and y>3
-
3-4Saemen()Delphi sum := sum + 1 ;
-
Block Saemen Compund Saemen begin...endend;begin t := a ; a := b ; b := t ;end;
-
Expression5+35+3i = 0 ; a = 3 ; b = 5 ;sum := 0 ;6 ; //64+5 ; //9sum > 3 ;//Falsei ; //0a + b ; //8sum := a + b ;//sum = 8
-
CommensDelphi x := x + 3; x3sum := sum + y; ysum* *//Delphisum := sum + y; //ysum