With Delphi macro can do some very simple work, it is recording the action of the keyboard, if we will have some regular action, with the macro to operate, you can achieve a multiplier effect, the premise is that the code style is relatively neat.
The macro starts with CTRL + SHIFT + R, also ends with CTRL + SHIFT + R, and plays with CTRL + SHIFT + P.
After you start recording a macro, you can see the word ' recording ' in the status bar.
Here are examples of assign, for example
As below, there are a whole bunch of variables in our class
DNO:STRING[20];
DWORKER:STRING[4];
Ddate:tdatetime;
DTRADE_S:STRING[10];
DTRADE_E:STRING[10];
Dmoney_sale:real;
Dmoney_last:real;
Dmoney_ss:real;
DMAN:STRING[2]; Guest floor
Dmoney_sk:real; Collection
Dmoney_zl:real; Change
Money_mode:real; Cash payment Amount
Ticket_mode:real; Purchase Voucher Payment Amount
Czk_mode:real; Amount of the stored value card payment
Mzk_mode:real; Value Card Payment Amount
Bank_mode:real; Bank Card Payment Amount
DCARD_ZK:STRING[20]; Discount Card number
DCARD_HL:STRING[20]; Hung Lee Card number
DSUBSHOP:STRING[4];
DSALESMAN:STRING[4]; Salesperson
We want to assign its value to the value of a Asource object in assign, as follows.
For example:
Procedure Tmasterdata.assignvalue (Asource:tmasterdata);
Begin
Want the following results
DNO: = Asource.dno;
Dworker: = Asource.dworker;
Ddate: = asource.ddate;
dtrade_s: = asource.dtrade_s;
Dtrade_e: = Asource.dtrade_e;
Dmoney_sale: = Asource.dmoney_sale;
Dmoney_last: = Asource.dmoney_last;
What are we going to do, first copy the declaration down and form the following
Procedure Tmasterdata.assignvalue (Asource:tmasterdata);
Begin
DNO:STRING[20];
DWORKER:STRING[4];
Ddate:tdatetime;
DTRADE_S:STRING[10];
DTRADE_E:STRING[10];
Dmoney_sale:real;
Dmoney_last:real;
....
At this point, we will focus on the beginning of the DNO line, press CTRL + SHIFT + R to start recording, and then press the ctrl+-> arrow, the cursor will move to the front of the word dno, and then press CTRL + SHIFT +->, will choose DNO: This section, more than two characters how Do, press SHIFT + <-Arrow two times, now fully select the DNO, press CTRL + C, copy, then press the arrow, then press the <-arrow back: Before, then, enter: = Asource. These letters, and then press CTRL + V paste, now become dno: = asource.dno:string[20]; Cursor in the second: before we clear the next character, press SHIFT + END, then press the DELETE key, so that the first column is completed, and then for convenience, we will position the cursor to the beginning of the second line, down arrow, and then press the home key.
This is all of our buttons, we press CTRL + SHIFT + R to end the recording, then press CTRL + Shift+ P to play it, very cool
If you are very familiar with the Delphi macros, then we can make a lot of wonderful things, such as we often have in the MSSQL
Update a set dnum = B.dnum This kind of thing, completely can use the Delphi macro to complete.
The key points of recording a macro,
1 must pay attention to the law of writing code neat
2 multi-use CTRL + SHIFT + ARROW to select words
3 All the operation must be done with the keyboard, what do not understand can contact me. Contact method [email protected]
Http://www.cnblogs.com/qiubole/articles/116104.html
IDE macro recording Small in Delphi