|
|
Re: [Xpand] How to save local variables in nested for loop [message #648036 is a reply to message #648024] |
Mon, 10 January 2011 22:22 |
Eclipse User Messages: 14 Registered: January 2011 |
Junior Member |
|
|
Hi Christian,
Here's a example of the loop I'm trying to use in my Xpand template:
«DEFINE Root FOR MyProfile::MyPackageStereotype»
«FOREACH ownedType.typeSelect(MyProfile::MyInterfaceStereotype) AS p»
«FOREACH p.ownedOperation.typeSelect(MyProfile::MyOperationStereotype ) AS e»
«FOREACH e.ownedParameter.typeSelect(MyProfile::MyParam) AS param»
«REM» «IF param.level == "LOW"»
//would like to save to local var here
«ELSEIF param.level == "MEDIUM"»
//would like to save to local var here
«ENDIF» «ENDREM»
«ENDFOREACH»
«name», «p.name», «e.name», ... //would like to output "LOW" param followed by "MEDIUM" param
«ENDFOREACH»
«ENDFOREACH»
«ENDDEFINE»
I did try out the select statement in my sandbox Xpand template:
«DEFINE MyParamRoot FOR MyProfile::MyParam»
«FILE name+".txt"»
«LET this.ownedParameter.select(param | (param.level == "LOW")) AS foo»
«foo.name»
«ENDLET»
«ENDFILE»
«ENDDEFINE»
The output for this was:
[ ]
when I was expecting the name of the parameter.
Hopefully this provides sufficient detail for more specific guidance.
As a point of clarification, the two template samples provided were separate tests that do not depend on each other.
Thanks again!
[Updated on: Mon, 10 January 2011 22:24] Report message to a moderator
|
|
|
Re: [Xpand] How to save local variables in nested for loop [message #648037 is a reply to message #648036] |
Mon, 10 January 2011 22:31 |
|
hi, what about
«DEFINE Root FOR MyProfile::MyPackageStereotype»
«FOREACH ownedType.typeSelect(MyProfile::MyInterfaceStereotype) AS p»
«FOREACH p.ownedOperation.typeSelect(MyProfile::MyOperationStereotype ) AS e»
«name», «p.name», «e.name», «e.ownedParameter.typeSelect(MyProfile::MyParam).select(x|x.level == "LOW").collect(x|x.name).toString(",")»
, «e.ownedParameter.typeSelect(MyProfile::MyParam).select(x|x.level == "MEDIUM").collect(x|x.name).toString(",")»
«ENDFOREACH»
«ENDFOREACH»
«ENDDEFINE»
~Christian
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
Powered by
FUDForum. Page generated in 0.02665 seconds