Skip to main content



      Home
Home » Modeling » VIATRA » Type Casting
Type Casting [message #1292954] Sat, 12 April 2014 02:55 Go to next message
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
Hi,
Thank you. It now works.

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


Current Time: Sun Jul 27 14:32:29 EDT 2025

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

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

Back to the top