Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><code>clHotlight: TColor = $00FF9933;</code> is not a constant but a typed constant (=static variable), i.e. the compiler reserves a slot in memory for a TColor which will hold the value <code>$00FF9933</code> initially at run time.<br> Because that value can be changed later (with the Assignable Const option ON), it is not a real constant and cannot be accepted by the compiler in <code>clLink = clHotLight;</code> </p> <p><code>clHotlight = TColor($00FF9933);</code> is strictly the same as <code>clHotlight = $00FF9933;</code><br> It is a true constant and the compiler will replace <code>clHotlight</code> by its value <code>$00FF9933</code> wherever it appears in the code. And for <code>clLink</code> as well.</p> <p>Read on this SO question (<a href="https://stackoverflow.com/questions/48934/in-delphi-7-why-can-i-assign-a-value-to-a-const"><strong>In Delphi 7, why can I assign a value to a const?</strong></a>) and all the good answers there...</p> <p><strong>EDIT: about TGUID...</strong><br> The problem is that writing <code>AdministratorGUID: TGUID = '{DE44EEA0-6712-11D4-ADD4-0006295717DA}';</code> is not proper.<br> It is using some <strong>compiler magic</strong> to call <code>StringToGUID</code> behind the scene, allowing the convenience to express the GUID as a string which they are not by nature. They are records. </p> <p>So, trying <code>AdministratorGUID = '{DE44EEA0-6712-11D4-ADD4-0006295717DA}';</code> will not work. That is not a GUID...</p> <p>A workaround is to have <strong>a typed constant</strong> and <strong>variables</strong> pointing to the same memory area using the <strong><code>absolute</code></strong> directive: </p> <pre><code>const AdministratorGUID: TGUID = '{DE44EEA0-6712-11D4-ADD4-0006295717DA}'; var SuperuserGUID: TGUID absolute AdministratorGUID; //alias of AdministratorGUID RootGUID: TGUID absolute AdministratorGUID; //alias of AdministratorGUID </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload