-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPascal Ketwirds.txt
2273 lines (1370 loc) · 43.5 KB
/
Pascal Ketwirds.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
and array begin case const
div do downto else end
file for function goto if
in label mod nil not
of or packed procedure program
record repeat set then to
type until var while with
Type Minimum Maximum Format
Integer -2147483648 2147483647 signed 32-bit
Cardinal 0 4294967295 unsigned 32-bit
Shortint -128 127 signed 8-bit
Smallint -32768 32767 signed 16-bit
Longint -2147483648 2147483647 signed 32-bit
Int64 -2^63 2^63 - 1 signed 64-bit
Byte 0 255 unsigned 8-bit
Word 0 65535 unsigned 16-bit
Longword 0 4294967295 unsigned 32-bit
Name Type & Description
Character Typically a single octet (one byte). This is an integer type.
Integer The most natural size of integer for the machine.
Real A single-precision floating point value.
Boolean Specifies true or false logical values. This is also an integer type.
Enumerated Specifies a user-defined list.
Subrange Represents variables, whose values lie within a range.
String Stores an array of characters.
Operator Description
and Called Boolean AND operator. If both
the operands are true, then condition
becomes true.
and_then It is similar to the AND operator,
however, it guarantees the order in
which the compiler evaluates the
logical expression. Left to right
and the right operands are evaluated
only when necessary. (A and then B) is false.
or Called Boolean OR Operator. If any of
the two operands is true, then condition
becomes true. (A or B) is true.
or_else It is similar to Boolean OR, however, it
guarantees the order in which the compiler
evaluates the logical expression. Left to
right and the right operands are evaluated
only when necessary. (A or else B) is true.
not Called Boolean NOT Operator. Used to reverse
the logical state of its operand. If a condition
is true, then Logical NOT operator will make
it false. not (A and B) is true.
Bit Operators
Bitwise operators work on bits and perform bit-by-bit operation. All these operators work on integer operands and produces integer results. The truth table for bitwise and (&), bitwise or (|), and bitwise not (~) are as follows −
p q p & q p | q ~p ~q
0 0 0 0 1 1
0 1 0 1 1 0
1 1 1 1 0 0
1 0 0 1 0 1
--------------------------------------------------------------
Karthi Softek
home Home
listTopics
webOptions
Delphi, Lazarus reserved words, keywords detailed explanation
Blogs from oranges, in case, and other places
Reserved words: identifiers such as variables can be reused;
Keywords: have specific meaning and cannot be redefined;
Modifiers: functions similar to reserved words, which means that they can be reused;
Data type: The data type is similar to reserved words, and generally do not redefine;
Prompt word: This information is used to prompt the user for platform dependency and other purposes during compilation, and should not be changed.
But try not to redefine reserved words, such as the following code
procedure TForm1.FormCreate(Sender: TObject);
var true:string;
begin
end;
Can be executed correctly.
The same identifier is similar to a reserved word, the following program can also be executed:
type Integer= Char;
var I: Integer;
begin I:= 'A';
ShowMessage(I);end;
But the following program will report an error.
type string = Integer;
Therefore, it is best not to redefine the reserved words, identifiers, keywords, and modifiers;
Turbo pascal reserved word
and
array
asm
begin
break
case
const
constructor
continue
destructor
div
do0
downto
else
end
false
file
for
function
goto
if
implementation
in
inline
interface
label
mod
nil
not
object
of
on
operator
or
packed
procedure
program
record
repeat
set
shl
shr
string
then
to
true
type
unit
until
uses
var
while
with
xor
Object pascal reserved words
as
class
dispose
except
exit
exports
finalization
finally
inherited
initialization
is
library
new
on
out
property
raise
self
threadvar
try
Delphi keywords
And
Array
As
Begin
Case
Class
Const
Constructor
Destructor
Div
Do
DownTo
Else
End
Except
File
Finally
For
Function
Goto
If
Implementation
In
Inherited
Interface
Is
Mod
Not
Object
Of
On
Or
Packed
Procedure
Program
Property
Raise
Record
Repeat
Set
Shl
Shr
Then
ThreadVar
To
Try
Type
Unit
Until
Uses
Var
While
With
Delphi reserved words and keywords
Absolute
Abstract
And
Array
As
Asm
Assembler
Automated
Begin
Case
Cdecl
Class
Const
Constructor
Contains
Default
Destructor
Dispid
Dispinterface
Div
Do
Downto
Dynamic
Else
End
Except
Export
Exports
External
Far
File
Finalization
Finally
For
Forward
Function
Goto
If
Implementation
Implements
In
Index
Inherited
Initialization
Inline
Interface
Is
Label
Library
Message
Mod
Name
Near
Nil
Nodefault
Not
Object
Of
On
Or
Out
Overload
Override
Package
Packed
Pascal
Private
Procedure
Program
Property
Protected
Public
Published
Raise
Read
Readonly
Record
Register
Reintroduce
Repeat
Requires
Resourcestring
Safecall
Set
Shl
Shr
Stdcall
Stored
String
Then
Threadvar
To
Try
Unit
Until
Uses
Var
Varargs
Virtual
While
With
Write
Writeonly
Xor
The modified words supported by Freepascal include the reserved words turbopascal and object pascal (the red part is different from delphi)
absolute
abstract
alias
assembler
cdecl
cppdecl
default
export
external
forward
index
local
name
nostackframe
oldfpccall
override
pascal
private
protected
public
published
read
register
reintroduce
safecall
softfloat
stdcall
virtual
write
Modifiers no longer supported by Freepascal
=========================================================
far
near
ISO 7185 standard keywords
And
Downto
If
Or
Then
Array
Else
In
Packed
To
Begin
End
Label
Procedure
Type
Case
File
Mod
Program
Until
Const
For
Nil
Record
Var
Div
Function
Not
Repeat
While
Do
Goto
Of
Set
With
ISO 10206 extended pascal keywords
And_then
Import
Module
Otherwise
Qualified
Bindable
Implementation
Only
Pow
Restricted
Export
Interface
Or_else
Protected
Value
Turbo Pascal keywords
Absolute
Destructor
Inline
Shl
Uses
Asm
Implementation
Interface
Shr
Virtual
Constructor
Inherited
Object
Unit
Xor
Delphi add keywords
as
exports
initialization
on
threadvar
class
finalization
is
property
try
except
finally
library
raise
Free Pascal keywords
dispose
exit
false
new
true
Object Pascal keywords
Abstract
Constructor
Inherited
Object
View
Class
Destructor
Is
Property
Virtual
GNU keywords
All
Asm
Inline
Pascal expands scientific computing keywords
Module
Operator
Data type identifier
Integer
Shortint
SmallInt
Longint
Longword
Int64
Byte
Word
Cardinal
QWord
Boolean
ByteBool
WordBool
LongBool
Char
Real
Single
Double
Extended
Comp
Currency
Char
String
Shortstring
Ansistring
UnicodeString
WideString
Constantstring
PChar
Array
Record
VariantInteger
Shortint
SmallInt
Longint
Longword
Int64
Byte
Word
Cardinal
QWord
Boolean
ByteBool
WordBool
LongBool
Char
Real
Single
Double
Extended
Comp
Currency
Char
String
Shortstring
Ansistring
UnicodeString
WideString
Constantstring
PChar
Array
Record
Variant
In addition to the above variable types, there are also some predefined variable types of windows, fpc, and lcl. They are equivalent to the function of reserved words, and don't change them casually.
Proprietary hint words for Lazarus and freepascal
deprecated
experimental
platform
unimplemented
The following is a detailed explanation of each reserved word and keyword
======================================================
absolute // It enables you to create a new variable, and the starting address of the variable is the same as another variable.
abstract //It allows you to create abstract methods, including classes with abstract methods called abstract classes.
Abstract // keyword must be used with Virtual or Dynamic keyword at the same time, because abstract methods must be overridden.
// Abstract classes cannot be instantiated, abstract methods cannot contain method bodies.
and //1. means logical and
//2. represents bit operation
Array //Array is used to represent an array, any object can be declared as an array. Arrays are divided into two types: static and dynamic.
//Static array
//Dynamic array, because the number of elements is unknown at the time of declaration, you must use the SetLength method to set the size of the array later
as //As is used to transform one object into another
//For the conversion of the object filling interface, As must be used
asm //Asm keyword is used to insert assembly code. When using assembly code, you must use the structure of asm...end; instead of begin...end;
assembler //Assembler keyword is used to support early assembly, such as 80386.
automated //Automated access specifier is used to describe the members of an automatic type, which can make the version of the program backward compatible.
begin //begin keyword is used to indicate the beginning of a program or a structure, and the end keyword must be used to end.
case //Case statement is used to complete the condition selection. The selected object of the Case statement must be an ordered type, including integer types, enumeration types, character types, etc.
cdecl //Cdecl is a type of function calling convention, which specifies the rules that must be followed when calling functions from a DLL written in C or C++.
class //Class keyword is used to declare or inherit a class, or to make the class and interface inherit at the same time.
const //Const keyword is used to declare constants, and the data declared with const cannot be changed in the program.
constructor //constructor keyword is used to declare the constructor of a class. When the class is instantiated, this function is called first
//The constructor is generally represented by Create, and the Create method can be associated with the CreateWnd method that exists in the class.
type
ClassDemo = class(TObject)
private
fValue: Integer;
public
constructor Create;
end;
constructor ClassDemo.Create;
begin
fValue := 0;
end;
The contains//Contains keyword indicates whether a certain package (Package) contains a certain file.
//Files imported with Contains must be added to the package file, it can avoid losing references to key files.
package DATAX;
requires
rtl, clx;
contains
Db, DBLocal, DBXpress;
end.
The default//Default keyword is used to indicate the default value of an attribute
//Only attributes of ordered types allow the existence of default values, otherwise the attribute value must be initialized in the constructor.
type
ClassDemo = class
private
fValue: Integer;
published
property Value: Integer read fValue write fValue default 0;
end;
//It can also indicate the default attributes of a class
property strings[Index: Integer]: string read GetString write PutString; Default;
destructor //Destructor is used to identify the destructor, which is automatically called when the class is released.
dispid //DispId keyword is used in the DispInterface interface to specify a specific adaptation sequence number.
dispinterface //DispInterface is used to declare a specific adapter interface, which can accept incoming and outgoing data from the standard system interface.
div //Div is used to find the integer quotient of two numbers. The two values used for Div operation must both be of integer type, and the result of the operation must also be of integer type.
do //Do keyword is used in For, While, On, With statements to form a specific structure
downto //DownTo keyword is used in the For statement to indicate that the loop variable is decrementing.
for i := 100 downto 1 do
ListBox1.Items.Add(IntToStr(i));
//In the For statement, the To keyword is used to increase the loop variable, and the DownTo keyword is used to decrease it.
dynamic//Dynamic is used to declare a dynamic method,
//Dynamic methods can be overridden, and the code size can be reduced as much as possible (different from Virtual).
procedure X(i: Integer); dynamic;
else//else is used to guide the running direction of the program. It can be used in conjunction with If, Case and On statements. When the condition is not met, it will run under else
//If statement (in If statement, semicolon is not allowed before else):
if a > b then
c := a
else
c:=b;
//Case statement:
case Tag Of
1:Result:=1;
2:Result:=2;
3:Result:=3;
else
Result:=0;
end;
//On statement (exception handling):
try
i := StrToInt(s);
Excpet
on EZeroDivide do Result := 1;
on EOverflow do Result := 2;
else
Result := 0;
end;
end//End is used to end a statement block or a unit.
//It can match begin, Case, Class, Interface, Asm, Unit, Package, etc.
//For statement blocks (partial end), a semicolon must be added after End.
//For units or packages (global end), a period must be added after end.
//It is not allowed to add symbols after End before the else keyword in the If statement.
procedure X;
begin
with Button1 do
begin
if Button1.ShowHint then
Button1.Caption :='Hinted'
else
Button1.Caption :='Not Hinted';
end;
end;
//Use End in the package to end:
package DATAX;
requires
rtl,
clx;
contains Db, DBLocal, DBXpress;
end.
The except//except keyword is used for exception handling and must be used in a try statement. If an exception occurs, the statement after except is executed
try
i := StrToInt(s);
except
ShowMessage('Error!');
end;
export//Export indicates the function call contract, indicating that the function can be exported, and the exported function can be called locally or remotely.
//Other programs can call functions in the program in the form of dll. It is backward compatible.
function Add(a,b: Integer): Integer; export;
//If this program is compiled as Demo.exe, and another program needs to call this function, you can use the following statement
function Add(a,b: Integer): Integer; stdcall; external 'Demo.exe';
exports//exports is used to export objects, it must be used between the interface and the implementation, multiple items can be exported at the same time, and the items are separated by commas.
library Demo;
function X(i: Integer): string; stdcall;
begin
Result:=IntToStr(i);
end;
exports
X;
begin
end.
//If the output object is overloaded, you must give the object an alias and specify the parameters.
library Demo;
function X(i: Integer): string; overload; stdcall;
begin
Result := IntToStr(i);
end;
function X(s: string): Integer; overload; stdcall;
begin
Result := StrToInt(s);
end;
exports
X(i: Integer) name 'x1',
X(s: string) name 'x2';
begin
end.
The external//External keyword is used to refer to an external or OBJ method.
{$L Demo.OBJ}
procedure X(i:Integer);external;
//If it is referenced from a dll or an external program, you can use the following code:
function A(FileName: string): string; external 'Demo.dll';
//If the referenced function is overloaded, you must additionally indicate the referenced name.
function A(Name: string): string; overload; stdcall; external 'Demo.dll' name 'A1';
function A(Code: Integer): string; overload; stdcall; external 'Demo.dll' name 'A2';
//When using the External keyword, you must pay attention to the case, otherwise an error will occur.
far//Far indicates the function call contract, indicating that the function can be called remotely.
//Other programs can call functions in the program in the form of dll. It is backward compatible.
function Add(a,b: Integer): Integer; Far;
//If this program is compiled into Demo.exe, and another program on another computer needs to call this function, you can use the following statement:
function Add(a,b: Integer): Integer; stdcall; external 'Demo.exe';
The file//File keyword indicates the type of file operation, the file must be declared as File,
//If you append Of and file type after File, the file can be defined to read and write data of the specified type.
type
TPerson = record
PName: string[32];
PAge: Integer;
end;
var
PFile: file of TPerson;
The finalization//finalization keyword identifies the method to be called when the unit is released.
//Usually release objects that cannot be automatically released in the unit, or not.
//The most common case of finalization is to deinitialize OLE objects.
initialization
ActiveX.OleInitialize(nil);
finalization
ActiveX.OleUninitialize;
The finally//finally keyword points out the last method that must be called in exception handling.
//Regardless of whether an exception occurs, the statement after the finally is always executed at the end of the try statement.
try
Node := Node.GetNext;
Edit1.Text := Node.Text;
finally
Node := nil;
end;
The for//For keyword leads to the For loop structure, which is used to loop a specified number of times.
for i := 1 to 100 do sum := sum + i;
//If the loop variable is decreasing, you can use the DownTo keyword
for i := 100 downto 1 do Inc(sum);
The forward//Forward keyword is used to pre-define a method. Only define the method declaration, and then implement the method at the back of the program.
//This is conducive to the readability of the code, you can put all the declarations together, and then put all the implementations together.
function X(i: Integer): Integer; forward;
procedure Y(s: string); forward;
...
function X;
begin
Result := i * 2;
end;
procedure Y;
begin
WriteLn(s);
end;
//The method of forward declaration does not need to enter the method parameters and return value when implementing it, just use the method name directly.
function//Function is used to declare functions
function X(i: Integer): Integer;