0

I want to use user variables in a custom plugin written in Bright-Script. Those variables are defined in Bright-Author during the process of creating a presentation. I tried bringing those in the script by using the user-Variables associative array but it didn't work.

Here is the piece of code that I am trying to use:

Sub data2(xmlFileName as String, itemsByIndex as object, itemsByTitle as Object, userVariables As Object)
  print userVariables["uservariablename"]
end Sub
peterh
  • 11,875
  • 18
  • 85
  • 108

2 Answers2

0

Try this:

print userVariables.Lookup("uservariablename").GetCurrentValue()
Udi
  • 16
  • 1
0

Udi's answer will indeed work. However, in case anyone else sees this and wants a little more info on user variables, here it is...

The 'userVariables' argument to script plugin functions is indeed an associative array, and the member values of that array (keyed by user variable name) are objects which contain the current value of user variable (a string,) the default value, user access permission (shared or private,) and some other info for special user variables.

The object also contains the functions GetCurrentValue, SetCurrentValue, Increment, and Reset. You should use these functions for manipulating the variable content (as Udi did to read it.)

The Reset function resets the variable to its default value, and Increment will increment it, but only if the string can be parsed into a number.

jims
  • 940
  • 7
  • 5
  • Thanks for the additional information! Is there a documentation for these functions? – Lovepreet Jassal Sep 14 '17 at 16:25
  • Unfortunately, no. Script plugins are a advanced feature. The current documentation for plugins is here: http://docs.brightsign.biz/display/DOC/BrightAuthor+Plugins+and+Parsers. In that documentation, the userVariables object is not really specified. This object is defined and maintained in the main autorun script, and my answer here was intended to shed some light on how it is set up. I will see if we can add this description to the official documentation. Since plugins can be used to extend the standard autorun (which changes a bit with each release,) it is pretty difficult to document. – jims Sep 17 '17 at 13:46
  • I guess I could add a bit: GetCurrentValue() always returns a string value. SetCurrentValue(value as object, postMsg as boolean) sets the value, where value should be a string or an integer - integers are converted to a string. If postMsg is true, a "USER_VARIABLE_CHANGE" event is emitted. Increment() attempts to convert to an integer, increments it, and converts back to a string. Reset() resets the variable to the default value. – jims Sep 17 '17 at 14:09