# Int array in a rule

Hi!

I have to convert a C program for my humidity conversion calculation. For this I need a array like this:

``````const WORD pressure[120] = {
103, 114, 125, 137, 150, 165, 181, 198, 217, 237, 260, 284, 310, 337,
368, 401, 437, 476, 517, 562, 611, 657, 705, 759, 813, 872, 935, 1002,
1073, 1148, 1228, 1312, 1403, 1498, 1599, 1706, 1818, 1937, 2065,
2197, 2340, 2487, 2645, 2810, 2985, 3169, 3362, 3566, 3781, 4006, 4244,
4493, 4755, 5030, 5320, 5623, 5942, 6276, 6627, 6995, 7381, 7785, 8208, 8652,
9116, 9602, 10110, 10642, 11198, 11780, 12388, 13023, 13687, 14380, 15103,
15858, 16646, 17468, 18326, 19220, 20152
};
``````

How can i achieve that in a rule?

cheers
Martin

I think it would look like this:

``````val int[] pressure = #[
103, 114, 125, 137, 150, 165, 181, 198, 217, 237, 260, 284, 310, 337,
368, 401, 437, 476, 517, 562, 611, 657, 705, 759, 813, 872, 935, 1002,
1073, 1148, 1228, 1312, 1403, 1498, 1599, 1706, 1818, 1937, 2065,
2197, 2340, 2487, 2645, 2810, 2985, 3169, 3362, 3566, 3781, 4006, 4244,
4493, 4755, 5030, 5320, 5623, 5942, 6276, 6627, 6995, 7381, 7785, 8208, 8652,
9116, 9602, 10110, 10642, 11198, 11780, 12388, 13023, 13687, 14380, 15103,
15858, 16646, 17468, 18326, 19220, 20152
]
``````

At the declaration i get the error:

``````"no viable alternative at input '#'"
``````

And when I try to access a element like pressure[1]:

``````Cannot access local variable pressure with parentheses
``````

In the log file I see this error:

``Error during the execution of rule 'Kellerlueftung': feature was simple feature call but got receiver instead of null. Receiver: Proxy for org.eclipse.xtext.xbase.lib.Functions\$Function1: org.eclipse.xtext.xbase.impl.XClosureImplCustom@11ff68 (explicitSyntax: false)``

openHAB is apparently using some subset of Xtend. You might have to use `newArrayList(...)` instead of `#[...]`. I’ve found Xtend powerful, and yet frustrating because it’s not well documented.

Thx for the hint. Now it works!

Martin