Search code examples
ocl

OCL at0 operator syntax error


Working on a timereport project in MDriven and I have created an instance where an employee has worked ten hours. The Employee class's "attribute.type" is of "timespan" for "HoursWorked".

action:
Employee.create
Employee.allinstances->at0(0) .HoursWorked:= 10:00:00

This code gives me a syntax error. Is the at0 not functioning with "timespan"? If so, which expression should be used in this case to create a certain timespan?

Also, if anyone knows a good, informative wiki with all the OCL expressions and how to correctly write syntax that would be much aprreciated.


Solution

  • The issue is that the MDriven action language (based on OCL but with side effects allowed) requires you to separate statements with ;

    Try:

    action:
    Employee.create;  -- notice that semicolon
    Employee.allinstances->at0(0).HoursWorked:= TimeSpan.Create(10,00,00)  --NO ; on end statement