Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Incremental for loop
Incremental for loop [message #1753437] Mon, 06 February 2017 13:18 Go to next message
Julien Pourille is currently offline Julien PourilleFriend
Messages: 8
Registered: February 2017
Junior Member
Hye everyone,

Can everyone can explain me (I'm new on Acceleo) how to do this with acceleo syntax :

for(int i = 0; i < X && Y > Z; i++){
...
}

I have seen syntax of for loop for acceleo which use a collection as input. But for me i want to write a piece of code X times so i want an incremental and conditional for loop to do this.

Is it possible and if yes, how to do this?

Thank you for your responses!

Re: Incremental for loop [message #1753559 is a reply to message #1753437] Tue, 07 February 2017 17:27 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Maybe there is a typo since Y and Z seem nothing to do with the loop.

Sequence{1..X}->forAll(i | ...)

is a useful idiom for a loop.

Regards

Ed Willink
Re: Incremental for loop [message #1754107 is a reply to message #1753559] Tue, 14 February 2017 14:49 Go to previous messageGo to next message
Julien Pourille is currently offline Julien PourilleFriend
Messages: 8
Registered: February 2017
Junior Member
Hi,

Thank your for your response,

I didn't know this Sequence create syntax. And actually, with this syntax it is possible to create an incremental loop like that :

[let maxCount : Integer = 20]
    [for aValue : Integer | Sequence{0..maxCount}]
        coucou : [aValue/]
    [/for]
[/let]


Thank you very much! Subject Resolved!
Re: Incremental for loop [message #1754108 is a reply to message #1753559] Tue, 14 February 2017 14:49 Go to previous messageGo to next message
Julien Pourille is currently offline Julien PourilleFriend
Messages: 8
Registered: February 2017
Junior Member
Hi,

Thank your for your response,

I didn't know this Sequence create syntax. And actually, with this syntax it is possible to create an incremental loop like that :

[let maxCount : Integer = 20]
    [for aValue : Integer | Sequence{0..maxCount}]
        coucou : [aValue/]
    [/for]
[/let]


Thank you very much! Subject Resolved!
Re: Incremental for loop [message #1754109 is a reply to message #1753559] Tue, 14 February 2017 14:50 Go to previous message
Julien Pourille is currently offline Julien PourilleFriend
Messages: 8
Registered: February 2017
Junior Member
Hi,

Thank your for your response,

I didn't know this Sequence create syntax. And actually, with this syntax it is possible to create an incremental loop like that :

[let maxCount : Integer = 20]
    [for aValue : Integer | Sequence{0..maxCount}]
        coucou : [aValue/]
    [/for]
[/let]


Thank you very much! Subject Resolved!
Previous Topic:[Acceleo] Generation in one thread
Next Topic:[Acceleo] pb with java services
Goto Forum:
  


Current Time: Tue Apr 23 07:00:53 GMT 2024

Powered by FUDForum. Page generated in 0.02753 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top