Jump to content
Sign in to follow this  
dormky

$FFFF can both be const and not ?

Recommended Posts

const
  TT = $FFFF;
  TTARRAY = [$FFFF];

The second line gets "E1012 Constant expression violates subrange bounds", but it's functionally the same as the first one. Is the compiler just dumb or do I need to write this in another syntax ?

 

The actual use case is an array of const TColor. Thanks 🙂

Share this post


Link to post

Despite its name the TTARRAY declaration is a set and not an array, but sets are limited to elements with ordinal 0..255.

  • Thanks 1

Share this post


Link to post

Alright, got it. Still cannot work with TColor but it's better then nothing, example :

  // The highlight colors here are defined twice so the compiler doesn't complain.
  YELLOW: TColor = $00BBFF;
  BLUE: TColor = $F0CF89;
  HIGHLIGHT_COLORS: array[0..1] of TColor = ($00BBFF, $F0CF89);

Thanks !

Share this post


Link to post

I have no problem to compile it:

 

const
// The highlight colors here are defined twice so the compiler doesn't complain.
  YELLOW = $00BBFF;
  BLUE = $F0CF89;
  HIGHLIGHT_COLORS: array[0..1] of TColor = (YELLOW, BLUE);

You can also compile:

 

const
// The highlight colors here are defined twice so the compiler doesn't complain.
  YELLOW = TColor($00BBFF);
  BLUE = TColor($F0CF89);
  HIGHLIGHT_COLORS: array[0..1] of TColor = (YELLOW, BLUE);

 

Edited by Lajos Juhász

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×