variables in plugin fields?

Got a good idea? You can suggest new features here.
Post Reply
V_J
Experienced User
Posts: 237
Joined: Tue Mar 04, 2014 9:00 am

variables in plugin fields?

Post by V_J » Sun Apr 26, 2020 2:54 pm

Just an idea... Many plugins use text fields that can be sent, recognized or whatever, but usually those textfields are fixed when the action is created. For example, for the serial plugin, this thread ( http://eventghost.net/forum/viewtopic.p ... ast#p47766 ) has the instructions on how to make a small script that uses functions from the plugin to send variable data (eg.result or whatever).

Perhaps this could be generalized, with some escape sequence? E.g. if you write $eg.result$ in the text field, it is parsed as the content of the variable, the $ sign could be by $$ for example... Looking at it the way Eventghost works, I guess this would rather be a change in the individual plugins than a change in Eventghost, but perhaps some standard for this could be defined for developers, so that plugin writers know which syntax would be common for this purpose?

Sem;colon
Plugin Developer
Posts: 697
Joined: Sat Feb 18, 2012 10:51 am
Location: Germany

Re: variables in plugin fields?

Post by Sem;colon » Sun Apr 26, 2020 8:58 pm

Hello Jörg,
Actually this is already in place.. if I recall that correctly the function that needs to be used be plugin developers is eg.parseString(). It replaces the variable in curly brackets with its content e.g. "blabla{eg.result}blabla"
If you like my work, Image me a drink :wink:

V_J
Experienced User
Posts: 237
Joined: Tue Mar 04, 2014 9:00 am

Re: variables in plugin fields?

Post by V_J » Mon Apr 27, 2020 7:25 am

I missed that one (probably forgot it from so many years ago not doing anything in EventGhost)...
(I tested it in the Broadcaster plugin and it works)
Thanks!

User avatar
kgschlosser
Site Admin
Posts: 5397
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: variables in plugin fields?

Post by kgschlosser » Thu Apr 30, 2020 8:25 am

when using the curly braces in a text entry field it does a whole lot more then simply replacing with the contents of a variable. It can run python code as well.


take this as an example. Say you wanted to add some text to the content of eg.result
{eg.result + "some text"}

or maybe you want to open a file and read the contents of that file when the action runs.
{open(r'c:\some_file.txt', 'r').read()}

you can even do more complex python expressions
{', '.join(item.strip() for item in eg.result if '.' not in item)}

This one is a favorite of mine for a volume OSD
{'|' * eg.event.payload + ('.' * (100 - eg.event.payload)) + ' ' + str(round(float(eg.event.payload), 2)) + '%'}
If you like the work I have been doing then feel free to Image

V_J
Experienced User
Posts: 237
Joined: Tue Mar 04, 2014 9:00 am

Re: variables in plugin fields?

Post by V_J » Thu Apr 30, 2020 8:59 am

Ok, that is great info! Not sure if I need it, but wow... :)

Post Reply