Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » how to define an array
how to define an array [message #968266] Fri, 02 November 2012 06:21 Go to next message
Kosala Yapa is currently offline Kosala Yapa
Messages: 159
Registered: September 2010
Senior Member
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 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 3844
Registered: July 2009
Senior Member
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 #968450 is a reply to message #968379] Fri, 02 November 2012 09:23 Go to previous messageGo to next message
Kosala Yapa is currently offline Kosala Yapa
Messages: 159
Registered: September 2010
Senior Member
Thanks a mil Ed
Re: how to define an array [message #968666 is a reply to message #968379] Fri, 02 November 2012 12:52 Go to previous messageGo to next message
Kosala Yapa is currently offline Kosala Yapa
Messages: 159
Registered: September 2010
Senior Member
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
Re: how to define an array [message #968790 is a reply to message #968666] Fri, 02 November 2012 15:07 Go to previous message
Dennis Wagelaar is currently offline Dennis Wagelaar
Messages: 131
Registered: September 2012
Senior Member

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


Cheers,
Dennis
Previous Topic:how to write for logic
Next Topic:how to write "for" logic in ATL
Goto Forum:
  


Current Time: Sun Apr 20 09:28:09 EDT 2014

Powered by FUDForum. Page generated in 0.01539 seconds