Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Acces a single element in a list of events(I am trying to get access to a single element in a list)
Acces a single element in a list of events [message #1793780] Wed, 15 August 2018 19:20 Go to next message
Stevo McLaren is currently offline Stevo McLarenFriend
Messages: 26
Registered: July 2018
Junior Member
These are my events:

event warte,Verschlussstand,ID_Test, Reinigen,Kaffee,Latte,Error,Fill

Now When I do this: «FOR s:machine.events» «s.name» «ENDFOR» I receive this [warte, Verschlussstand, ID_Test, Reinigen, Kaffee, Latte, Error, Fill] which is normal

Now I wish to have just the first event(warte) of the list. How do I proceed?

I thought of somthing like this --> machine.events->0 to have only "warte" but it doesnt work.

Thanks for helping

Re: Acces a single element in a list of events [message #1793781 is a reply to message #1793780] Wed, 15 August 2018 19:22 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
what do you mean by does not work?

«statemachine.events.head.name»


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Acces a single element in a list of events [message #1793782 is a reply to message #1793781] Wed, 15 August 2018 19:28 Go to previous messageGo to next message
Stevo McLaren is currently offline Stevo McLarenFriend
Messages: 26
Registered: July 2018
Junior Member
I just tried «statemachine.events.head.name» and it gave me this [warte, Verschlussstand, ID_Test, Reinigen, Kaffee, Latte, Error, Fill]
Re: Acces a single element in a list of events [message #1793783 is a reply to message #1793781] Wed, 15 August 2018 19:33 Go to previous messageGo to next message
Stevo McLaren is currently offline Stevo McLarenFriend
Messages: 26
Registered: July 2018
Junior Member
Any other suggestions?? Please!!!!
I really need to be able to access avery single element of that list. Thanks for your Help.
Re: Acces a single element in a list of events [message #1793784 is a reply to message #1793783] Wed, 15 August 2018 19:35 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
please give a complete example

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Acces a single element in a list of events [message #1793785 is a reply to message #1793784] Wed, 15 August 2018 19:37 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
are you sure events is not a list of lists? that would explain the [] in your output

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Acces a single element in a list of events [message #1793786 is a reply to message #1793785] Wed, 15 August 2018 19:46 Go to previous messageGo to next message
Stevo McLaren is currently offline Stevo McLarenFriend
Messages: 26
Registered: July 2018
Junior Member
Exactly I got abit irritated when I saw the braces"[ ]". Well I just uploaded the pictures of what im doing right now. I hope with thos Info you will get my problems. Thanks again.
  • Attachment: codegen.PNG
    (Size: 14.19KB, Downloaded 55 times)
  • Attachment: test.PNG
    (Size: 3.10KB, Downloaded 63 times)
  • Attachment: gramw.PNG
    (Size: 8.13KB, Downloaded 76 times)
Re: Acces a single element in a list of events [message #1793787 is a reply to message #1793786] Wed, 15 August 2018 19:53 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
in your case a event is a list of names. so you want the first name in the first event?

=> you can use

«statemachine.events.head.name.head»

maybe you should rename "name" to "names" in the grammar to make clear it is a list.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Acces a single element in a list of events [message #1793828 is a reply to message #1793787] Thu, 16 August 2018 15:16 Go to previous messageGo to next message
Stevo McLaren is currently offline Stevo McLarenFriend
Messages: 26
Registered: July 2018
Junior Member
Im very greatful for your help. I will make the changes and give you a feedback.
Re: Acces a single element in a list of events [message #1793831 is a reply to message #1793787] Thu, 16 August 2018 16:33 Go to previous messageGo to next message
Stevo McLaren is currently offline Stevo McLarenFriend
Messages: 26
Registered: July 2018
Junior Member
Thanks alot it works. Now I wish to get the second, third, fouth ... element. How do I proceed? Thanks for the hint.
Re: Acces a single element in a list of events [message #1793832 is a reply to message #1793831] Thu, 16 August 2018 16:40 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
«FOR n : statemachine.events.map[name].flatten».....

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Acces a single element in a list of events [message #1793835 is a reply to message #1793832] Thu, 16 August 2018 17:03 Go to previous messageGo to next message
Stevo McLaren is currently offline Stevo McLarenFriend
Messages: 26
Registered: July 2018
Junior Member
Im sorry my question was not clear. My aim is to grab the second element Only. I wish acces to every single element. For example

«machine.events.head.names.head» --> for the first element.
What about the second?
What about the third?

Sorry for asking so many questions. Im really new to xtext and I find it interesting. Thanks again for your help. Im greatful
Re: Acces a single element in a list of events [message #1793836 is a reply to message #1793835] Thu, 16 August 2018 17:31 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
list.get(i)

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:C-like multiple declaration
Next Topic:How to select an event from numerous events
Goto Forum:
  


Current Time: Fri Apr 19 00:45:39 GMT 2024

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

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

Back to the top