Alex Rivera | Logout

Can I assign items in an array all at once in Delphi/Pascal?

Asked 2011-06-27T13:38:30.833
21

I want to do something like in PHP, Python and most other programming languages:

my_array_name = [128, 38459, 438, 23674...] 

So I tried to replicate this in Delphi/Pascal the best I could:

HSVtoRGB := [0, 0, 0];

(this is for a function which returns an RGB array given HSV values.)

But I am getting errors:

[DCC Error] Unit2.pas(44): E2001 Ordinal type required
[DCC Error] Unit2.pas(45): E2010 Incompatible types: 'HSVRealArray' and 'Set'

Any idea? This is school work - but my teacher didn't know the answer.

Edit
Report

1 Answer

0

[0, 0, 0] is a set in Delphi. (0, 0, 0) is an array constant in Delphi! Just use:

HSVtoRGB := (0, 0, 0);

(Unless HSVtoRGB is a dynamic array. Did you declare it as var HSVtoRGB: array[1..3] of integer; or something similar?

answered 2011-06-28T09:09:03.313

Your Answer