Author Topic: Confused about passing variables into a pluguin function  (Read 3312 times)

Robertsmania

  • Newbie
  • *
  • Posts: 46
Confused about passing variables into a pluguin function
« on: February 10, 2022, 05:56:12 PM »
I have the framework for a plugin working!  Its amazing and very exciting.

Now that I'm fleshing it out with additional logic, I'm confused about passing variables to the plugin and scope.

I've read the documentation several times and experimented with the samples.

From what I see in practice, the fields on the Execute an External Plugin Function dialogue box are superfluous.  Is that true?  Are they vestigial from the previous versions of the plugin support and now no longer necessarily used?

When I first read through the documentation I thought, okay with the Context value you indicate what function logic to run inside VA_Invoke1.  Then with the Small Integer/Text/Decimal/Boolean/Date Variable fields you would specify parameters to be used along with that Context.

But what I see in practice is that if any command sets a variable, that variable is available inside VA_Invoke1 regardless of the Context or which command has called the plugin function.

vaProxy.GetText() will get the specified variable if its been set anywhere, whether its listed in the field for Text Variables on that command or not.

Reading further about variables and scope, I guess that makes sense with the idea that variables are scoped to the profile.  But I'm confused about whether there is something I'm missing with the fields on the dialog box and am missing an intended purpose?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4780
  • RTFM
Re: Confused about passing variables into a pluguin function
« Reply #1 on: February 10, 2022, 06:03:26 PM »
The fields in the "Execute an External Plugin Function" dialog are for backward-compatibility with plugins that still use the old interface, and have no function for plugins that use the version 4 interface, as mentioned in the documentation:
Quote from: VoiceAttackHelp.pdf, "Running a plugin from within VoiceAttack" subsection
NOTE: Any reference below this point regarding the variable input boxes (Small
Integer, Text, Integer, Decimal, Boolean and Date/Time) are there for backward
compatibility prior to version 4 of the plugin interface. They are not necessary for
use after version 4 (VoiceAttack version 1.6+), as you will be able to directly access
variables from within your plugin.

Also note that variables are, by default, globally scoped. I.E. they are available to any profile within the same session, unless you use a specific prefix to indicate a different scope.