Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsType Casting
https://www.eclipse.org/forums/index.php/mv/msg/692410/1292954/#msg_1292954
I have a question which I think is related to type casting.
In the model space there is an entity of type Sample with a relation of type amount to an entity of type datatypes.Integer (which also exists in the model space). The following transformation rule does not work
gtrule Calculate(out A,out B)= {
precondition pattern FindSample(A,B)= {
Sample(A);
datatypes.Integer(B);
Sample.amount(X,A,B);
}
action {
let Z= 1 in seq {
update Z = 4 * value(B);
}
}
}
(Operator '*' is undefined for the argument types ('datatypes.Integer', 'datatypes.String')
In fact, I need to do some computations using the value of an entity.
Thanks for your help.
]]>Reza Gorgan2014-04-12T06:55:28-00:00Re: Type Casting
https://www.eclipse.org/forums/index.php/mv/msg/692410/1294749/#msg_1294749
if I recall correctly, the call value(B) gives a string return value. If you know, that the correct value is an integer, you could use the toInteger conversion operator, such as follows (I hope, I remember the syntax):
action {
let Z= 1 in seq {
update Z = 4 * toInteger(value(B));
}
Cheers,
Zoltán]]>Zoltan Ujhelyi2014-04-13T19:26:45-00:00Re: Type Casting
https://www.eclipse.org/forums/index.php/mv/msg/692410/1296736/#msg_1296736
Thank you. It now works.