Using DELPHI macros can do some very simple tasks. It records keyboard actions. If we use some regular actions to operate with macros, we can achieve twice the result with half the effort, provided that the code written is relatively neat.
The macro starts with Ctrl + Shift + R, ends with Ctrl + Shift + R, and plays with Ctrl + Shift + P.
After you start recording the macro, you can see the words 'Recording' in the status bar.
The following is an example of Assign
As follows, there are a lot 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; //Cash collection
dMoney_ZL: Real; // Find change
Money_Mode: Real; //Cash payment amount
Ticket_Mode: Real; //The amount of shopping voucher payment
Czk_Mode: Real; //Paid value card payment amount
MZk_Mode: Real; //Pre-value card payment amount
Bank_Mode: Real; //Bank card payment amount
dCard_Zk: string[20]; //Discount card number
dCard_Hl: string[20]; //Hongli Kaka number
dsubshop: string[4];
dsalesman: string[4]; //Salesperson
We want to assign its value to the corresponding value of an ASource object in Assign, as follows.
For example:
PRocedure TMasterData.AssignValue(ASource: TMasterData);
Begin
//I want to get 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 should we do? First copy the statement 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 time, we first focus on the beginning of the dno line, press Ctrl + Shift + R to start recording, then press Ctrl + -> arrow, the cursor will move to the front desk of the word dno, and then press Ctrl + Shift + ->, Dno will be selected: In this section, what should I do if there are two extra characters? Press Shift + <-arrow twice. Now dno is completely selected. Press Ctrl + C, copy, and then press ->arrow and then press <-Arrow returns to: before, and then enter:= ASource. Press Ctrl + V to paste these letters, and now it becomes dno := ASource.dno: string[20]; The cursor is in the second : Before, we clear the following characters, press Shift + End, and then press the delete key, so that the first column is completed. Then, for convenience, we position the cursor to the beginning of the second row, downward arrow, and then Press the Home button.
This is all our keys. Let's press Ctrl + shift + R to finish recording, then press Ctrl + Shift + P to play, it's very cool
If we are very familiar with the macros of delphi, then we can do a lot of wonderful things, such as we often have in MSSQL
update a set dnum = b.dnum can be completely accomplished using delphi macros.
Key points of recording macros,
1 Be sure to pay attention to the neat rules of writing code
2 Use ctrl + shift + -> arrows to select words
3 All operations must be completed using a keyboard. If you don’t understand, please contact me. Contact method [email protected]
dno := ASource.dno