Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » VIATRA » Type Casting
Type Casting [message #1292954] Sat, 12 April 2014 06:55 Go to next message
Reza Gorgan is currently offline Reza GorganFriend
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 19:26 Go to previous messageGo to next message
Zoltan Ujhelyi is currently offline Zoltan UjhelyiFriend
Messages: 392
Registered: July 2015
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 06:54 Go to previous message
Reza Gorgan is currently offline Reza GorganFriend
Messages: 2
Registered: April 2014
Junior Member
Hi,
Thank you. It now works.

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


Current Time: Fri Apr 19 22:30:17 GMT 2024

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

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

Back to the top