Delphi: All constants are constant, but some are more constant than others?

前端 未结 7 1354
眼角桃花
眼角桃花 2021-01-03 20:54

Consider:

const 
   clHotlight: TColor = $00FF9933;
   clLink = clHotLight; //alias of clHotlight

[Error] file.pas: Constant expression expected
         


        
7条回答
  •  北荒
    北荒 (楼主)
    2021-01-03 21:35

    welcome to Delphi evolution. in delphi 1 & 2, you can not assign initial constant value to a global var (ex: var xVar: Integer = 1). The only way you can do that is using const xVar: Integer = 1) and some where in you codes, you can then change it to somethingelse if desired. Until they get rid of this ancient feature, you can not using "const xVar: Integer" construct as a const value.

    Cheers A Pham

提交回复
热议问题