Recently, there are always some scattered things to handle, and to be responsible for the daily maintenance of colleagues, as well as some hardware and software issues. So there is not much time to use it. And more depressed is that many methods have not been successful due to a computer poisoning last weekend. The virus file is restored after the virus file is removed, and the RUN in the registry is also invalid, and several modifications also failed. In the end, an error occurred in judgment, and the system file is mistaken to delete the virus file, causing the system unable to start. Finally, Ghost has returned, helpless is too lazy, usually ghost is not in time, eventually recover only on a ghost file in the beginning of this year. At the same time, reading notes written on the second chapter last week also lost with the resumption of the system. . .
Winner lesson: Document is lost at desktop; Favorite folder is lost; FTP address is lost; some programs need to be reinstalled. After this lesson, let me know the importance of the GHOST document, and often update often, and make backups. Important files don't put them on the system disk, don't put it on your desktop, if you want to pay attention to the relevant files in Document and Setting.
Helpless, I have to reap over the part of the part, but notes are simple.
Chapter II Object Pascal Language (1)
First, annotation
{ramrk} or (* remark *) OR // Remark
Second, process and function characteristics
1. Form1.show; == form1.show ();
2. Overload: To add keyword overload
Procedure Hello; OVERLOAD;
Procedure Hello; OVERLOAD;
Procedure Hello (D: Double); OVERLOAD;
3. Default
The default value is to be placed in the end, assigns the value when declaring.
Procedure Hasdefval (s: string; I: integer = 0);
When referenced, HasDefVal ('Hello', 26) or HasdefVal ('Hello') is omitted for the default value I
Third, data type
Pascal's data type is more, and when the process or function is passed, the actual parameters must realize the same data type.
If you call the DLL or OBJ, you are not Delphi, pay attention to the data type match (see Book P23)
Survival period self-management type
In addition to A N S I S R I N g, D e l P H i provides several self-management types, including: Wi D E S T R I N g, Va R I a N T, O L E VA R I a N N T, I N T E R f A C E, D I S P i N T E R f A c E and dynamic arrays. Automatic recycling type, allocate space when using, and exit the scope automatically releases resources.
String: The type of string is more, and the storage space and usage are different. Now we often use String, the compiler defaults to the Ansistring type. This type has no length limit while compatible with the end of NULL. For the String type, you should also pay attention to the use of storage space, if the size of the space is specified, such as Str: String [8], when accessing STR [10] will cause memory errors.
For general applications, use the String type directly. VARIANT Type: Variable Type, Delphi will automatically convert according to operational conversion, but if you use a Variant type, you will extend the program code so that it is slower. But in some ways for data types, it is very flexible, with Variant is very good, there are many functions for Variant (P37-38)
EMPTY or NULL: Different, EMPTY is empty, and NULL is non-empty, its value is NULL.
Fourth, user-defined type
1. Record: Struct equivalent to C
Type
MyRec = Record;
I: integer;
D: double;
END;
use
VAR
N: myREC;
Begin
N.I: = 23;
n.d = 3.5;
END;
2. Collection: Pascal unique data type, must be ordered, characters, enumeration values
Type
TCharset = set of char;
Tenum = (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday);
TenumSet = set of tenum; // includes any combination of Tenum values, is a subset
TSUBRANGSET = set of 1..10
Note that one collection can only have 255 elements
use,
VAR
Charset: tcharset;
ENUMSET: TENUMSET;
AlphaSet: Set of 'a' .. 'Z';
Begin
Charset: = ['a' .. 'j', 'a', 'm'];
ENUMSET: = [Saturday, Sunday, Monday, Tuesday, Wednesday, Thursday, Friday];
Alphaaset: = []; // EMPTY
END;
3. Object: It can be used as a record type, but it also includes functions and processes.
Type
TchildObject = Class (tparentObject);
Somevar: integer;
Procedure someproc;
END;
4. Pointer: just the location of the memory. It seems that it is not necessary to write in Windows program, and if it is a bottom development, it may be large. When I learned C, I also focused on my pointer, but I have been all forgot now.
The second chapter is not as easy to understand like the first chapter, but it is also good. After all, it is a dead thing such as some grammar rules, but many is to understand and deeply understand. These grammar is based on programming, but only the book is not enough, it must be able to put these grammar rules in actual programming. At present, I am also lacking practical drills. This makes me very passive when programming, often in touch with some grammar rules, greatly reduces the efficiency of work.