How Increment Variable in loop [message #643852] |
Wed, 08 December 2010 13:41 |
Manuel Selva Messages: 189 Registered: July 2009 Location: Grenoble, France |
Senior Member |
|
|
Hi all, in my .mtl file (working on EMF model) I have the following loop
[for (param : Param | subCat.params)]
record.readPayload32("What to put here ??");
[/for]
What I want is to replace the "What to put here" by a value starting at 0 and incremented on each loop's iterration by
The Param EClass has an integer length attribute.
How can I acheive this ? I was not able to find any solution until now ...
Thanks in advance for your help,
Manu
http://manuelselva.wordpress.com/
|
|
|
Re: How Increment Variable in loop [message #643865 is a reply to message #643852] |
Wed, 08 December 2010 14:08 |
|
This is a multi-part message in MIME format.
--------------080702080304030006030107
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Hi Manuel,
Acceleo defines an implicit "i" variable for iterations in order to
handle such needs :
[for (param : Param | subCat.params)]
record.readPayload32([i/]);
[/for]
Laurent Goubet
Obeo
On 08/12/2010 14:41, Manuel Selva wrote:
> Hi all, in my .mtl file (working on EMF model) I have the following loop
>
>
>
> [for (param : Param | subCat.params)]
> record.readPayload32("What to put here ??");
> [/for]
>
>
> What I want is to replace the "What to put here" by a value starting at
> 0 and incremented on each loop's iterration by
>
> [param.length/] The Param EClass has an integer length attribute.
>
> How can I acheive this ? I was not able to find any solution until now ...
>
> Thanks in advance for your help,
> Manu
--------------080702080304030006030107
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"
YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------080702080304030006030107--
|
|
|
|
Re: How Increment Variable in loop [message #643879 is a reply to message #643873] |
Wed, 08 December 2010 14:59 |
|
This is a multi-part message in MIME format.
--------------070507050705010905060406
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Manuel,
This can still be done... but you'll need to iterate twice on your list :
-----
[for (param : Param | subCat.params)]
record.readPayload32([subCat.params->subSequence(0,
i).length->sum()/]);
[/for]
-----
Laurent Goubet
Obeo
On 08/12/2010 15:49, Manuel Selva wrote:
> Hi Laurent,
>
> Thanks for the answer but this is not exactly what I need. I nee to
> increment this variable with a field of my model:
>
> [param.length/]
>
> the output will look like for example (with 3 parameters of length 2,4,2
> respectively)
>
>
> record.readPayload32(0);
> record.readPayload32(2); // 0 + 2
> record.readPayload32(6); // 0 + 2 + 4
>
--------------070507050705010905060406
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"
YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------070507050705010905060406--
|
|
|
|
Re: How Increment Variable in loop [message #643904 is a reply to message #643883] |
Wed, 08 December 2010 16:09 |
|
This is a multi-part message in MIME format.
--------------070908010903090408080404
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Manuel,
subSequence is for Sequences... you have to use "subOrderedSet" on
OrderedSets :p.
Laurent Goubet
Obeo
On 08/12/2010 16:37, Manuel Selva wrote:
> Thanks again but I don't have the subSequence function:
>
> Cannot find operation (subSequence(Integer, Integer)) for the type
> (OrderedSet(Param))
>
> Any ideas about that ?
--------------070908010903090408080404
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"
YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------070908010903090408080404--
|
|
|
Powered by
FUDForum. Page generated in 0.04026 seconds