Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » VIATRA2 » Type Casting
Type Casting [message #1292954] Sat, 12 April 2014 02:55 Go to next message
Reza Gorgan is currently offline Reza Gorgan
Messages: 2
Registered: April 2014
Junior Member
Hello.
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.
Re: Type Casting [message #1294749 is a reply to message #1292954] Sun, 13 April 2014 15:26 Go to previous messageGo to next message
Zoltan Ujhelyi is currently offline Zoltan Ujhelyi
Messages: 200
Registered: July 2009
Senior Member
Hi Reza,

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
Re: Type Casting [message #1296736 is a reply to message #1294749] Tue, 15 April 2014 02:54 Go to previous message
Reza Gorgan is currently offline Reza Gorgan
Messages: 2
Registered: April 2014
Junior Member
Hi,
Thank you. It now works.

Regards,
Reza.
Previous Topic:transforming 10 million elements?
Goto Forum:
  


Current Time: Wed Jul 30 09:34:35 EDT 2014

Powered by FUDForum. Page generated in 0.02307 seconds