Skip to main content



      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 15:20 Go to next message
Eclipse UserFriend
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 15:22 Go to previous messageGo to next message
Eclipse UserFriend
what do you mean by does not work?

«statemachine.events.head.name»
Re: Acces a single element in a list of events [message #1793782 is a reply to message #1793781] Wed, 15 August 2018 15:28 Go to previous messageGo to next message
Eclipse UserFriend
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 15:33 Go to previous messageGo to next message
Eclipse UserFriend
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 15:35 Go to previous messageGo to next message
Eclipse UserFriend
please give a complete example
Re: Acces a single element in a list of events [message #1793785 is a reply to message #1793784] Wed, 15 August 2018 15:37 Go to previous messageGo to next message
Eclipse UserFriend
are you sure events is not a list of lists? that would explain the [] in your output
Re: Acces a single element in a list of events [message #1793786 is a reply to message #1793785] Wed, 15 August 2018 15:46 Go to previous messageGo to next message
Eclipse UserFriend
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 84 times)
  • Attachment: test.PNG
    (Size: 3.10KB, Downloaded 113 times)
  • Attachment: gramw.PNG
    (Size: 8.13KB, Downloaded 105 times)
Re: Acces a single element in a list of events [message #1793787 is a reply to message #1793786] Wed, 15 August 2018 15:53 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: Acces a single element in a list of events [message #1793828 is a reply to message #1793787] Thu, 16 August 2018 11:16 Go to previous messageGo to next message
Eclipse UserFriend
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 12:33 Go to previous messageGo to next message
Eclipse UserFriend
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 12:40 Go to previous messageGo to next message
Eclipse UserFriend
«FOR n : statemachine.events.map[name].flatten».....
Re: Acces a single element in a list of events [message #1793835 is a reply to message #1793832] Thu, 16 August 2018 13:03 Go to previous messageGo to next message
Eclipse UserFriend
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 13:31 Go to previous message
Eclipse UserFriend
list.get(i)
Previous Topic:C-like multiple declaration
Next Topic:How to select an event from numerous events
Goto Forum:
  


Current Time: Mon Jun 16 06:54:40 EDT 2025

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

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

Back to the top