Absolute in Delphi

Source: Internet
Author: User

ForAbsoluteIn fact, there were very few opportunities to use it. I only saw it when I read the company's code documentation. At that time, I also asked the experts, but I thought it was the same memory, however, I still feel deeply after reading the instructor's blog today. It seems that it is not just as simple as sharing the same memory.

Here is an example:

ProcedureTform1.formcreate (Sender: tobject );

Var 

Num: int64;

PT: tpointAbsoluteNum;

Arr:Array[0... 1]Of
IntegerAbsolutePT;

Begin 

PT. x: = 111;

PT. Y: = 222;

Showmessagefmt ('% d, % d', [Arr [0],
Arr [1]); {111,222} 

Showmessagefmt ('% d, % d', [NumShl32Shr32,
NumShr32]) ;{111,
222}

End;

For the three values, the relationship between num, pt, and arr through absolute all points to a fast memory area. After a volume changes, other values also change.

 

In addition, this is the first time you can see it. Maybe I still don't know much about it. Let's share it with you:

Var
Str: string [32];
StrLen: Byte absolute Str;
The purpose of using absolute here is that when you need to take the actual length of the Str variable in the future, you don't need to call the function, just take the StrLen variable directly.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.