how to define an array [message #968266] |
Fri, 02 November 2012 06:21  |
Eclipse User |
|
|
|
Hi there,
How to define an integer array of length 10 and declare it with all 0 values?
any help is appriciated.
Thanks in advance!
K
|
|
|
Re: how to define an array [message #968379 is a reply to message #968266] |
Fri, 02 November 2012 08:16   |
Eclipse User |
|
|
|
Hi
OCL and presumably ATL has no arrays, just Sequencers or OrderedSEts
So Sequence{0,1,2,3,4,5,6,7,8,9} or Sequence {0..9}
Regards
Ed Willink
On 02/11/2012 10:21, Kosala Yapa wrote:
> Hi there,
>
> How to define an integer array of length 10 and declare it with all 0
> values?
>
> any help is appriciated.
>
> Thanks in advance!
> K
|
|
|
|
|
Re: how to define an array [message #968790 is a reply to message #968666] |
Fri, 02 November 2012 15:07  |
Eclipse User |
|
|
|
Op 02/11/12 17:52, Kosala Yapa schreef:
> Hi Ed,
>
> using{
> modules:Sequence(source!ModuleItem)=a.getModules();
> maxSlot:Integer=modules->last().getSlotValue().toInteger();
> slots:Sequence(Integer)=Sequence{1..maxSlot};
> }
>
>
> This gives a compile error at slots.
>
> Could you tell me how to solve that?
>
>
> Thanks
> K
ATL currently does not support Sequence{1..n}. Workaround:
helper def : range(first : Integer, last : Integer) =
if last < first then
Sequence{}
else
thisModule.range(first, last - 1)->append(last)
endif;
Cheers,
Dennis
|
|
|
Powered by
FUDForum. Page generated in 0.07666 seconds