How to send a variable from XL TO a plugin

Help each other out

How to send a variable from XL TO a plugin

Postby WannaTheater on Wed Oct 07, 2009 9:58 pm

So as a first step to a requirement for my skin, I need to send a variable to a plugin. Something like:
%movies>rating%

I can use the XL "save to variable" command to stuff %movies>rating% into a variable named "myRating", but how can I push the CONTENTS of myRating into my plugin? (I've done this with sending FIXED strings into the plugin, but how can I send in a variable?)

What I am trying to accomplish is the following:
1) DETERMINE THE CURRENT MUSIC ZONE AND PASS THIS INTO A PLUGIN

Any help would be appreciated!

Thanks!
WannaTheater
 
Posts: 235
Joined: Thu Aug 24, 2006 11:35 am
Location: Florida

Re: How to send a variable from XL TO a plugin

Postby lpg on Sat Oct 10, 2009 1:35 am

Should ask this in the development section of the plugins. Take a look at some plugin source code. If you need some specific examples I can dig them up.
lpg
 
Posts: 296
Joined: Thu Apr 14, 2005 8:17 pm
Location: Chicago

Re: How to send a variable from XL TO a plugin

Postby WannaTheater on Sat Oct 10, 2009 12:53 pm

Thanks. I've looked through the dev section and have come up with nothing.

So if I have the following in a plugin:
Private Sub myFunction(ByVal myVariable As String)
'MsgBox(myVariable)
End Sub

In XL I run the event 'plugin command", and fill in the form with the plugin name, command, and in the Variables field I place HELLOWORLD
This works as expected, i.e. when I attach the event to a buttin, and push the button, I get the messagebox which contains the string "HELLOWORLD"

But what if I execute the command "save to variable," and make the Information field "HITHERE" and the set "Variable (Location)" to myVariable.
I would like to pass the variable (myVariable), and have the messagebox show "HITHERE"

Can Xlobby do this? Or is everything that gets passed into a plugin function a fixed string? (perhaps you can pass by pointer, etc). I tried
%myVariable% with no success.
WannaTheater
 
Posts: 235
Joined: Thu Aug 24, 2006 11:35 am
Location: Florida

Re: How to send a variable from XL TO a plugin

Postby lpg on Sat Oct 10, 2009 3:07 pm

You need to set up a recieving variable in the plugin. Look at it as the plugin does not have any place to put the variable that Xlobby has created. Remember a plugin is a seperate program and does not share memory space with xlobby.

Thake a look at xsend key (I have attached the file). You send it a command and a variable key. It then acts on what you have entered. This is a good example in VB. Download the plugin and test it out to see how it works.
Attachments
sendkey_vb.vb.txt
(10.51 KiB) Downloaded 266 times
lpg
 
Posts: 296
Joined: Thu Apr 14, 2005 8:17 pm
Location: Chicago

Re: How to send a variable from XL TO a plugin

Postby lpg on Sat Oct 10, 2009 3:12 pm

I think I misread what you are trying to do. Have you set up a test screen to see that xLobby is putting the data into you variable as you expect. Then I am curious what does the vb program see when you pass %myvariable%. I would expect that xLobby should resolve the variable and pass the data to the program. I need to think about this some more.
lpg
 
Posts: 296
Joined: Thu Apr 14, 2005 8:17 pm
Location: Chicago

Re: How to send a variable from XL TO a plugin

Postby lpg on Sat Oct 10, 2009 4:03 pm

Try this. Set up a variable in your plugin and put some data in it. Remember you need to expose the variable in the xlobby plugin interface. The make sure the data can show up on an xlobby screen. Next use the save to variable command and put data into the variable. The new data should be in the variable in the plugin. I wrote something to do the awhile ago but I cannot find the source.

Larry
lpg
 
Posts: 296
Joined: Thu Apr 14, 2005 8:17 pm
Location: Chicago

Re: How to send a variable from XL TO a plugin

Postby lpg on Sat Oct 10, 2009 5:09 pm

Here is an example of what I was talking about. The code is from the xstats plugin.

Code: Select all
public class Stats : XPlugin
   {
      private XPluginHelper xhelper;

      private string cpustats = "";
      private string diskstats = "";
      private string osstats = "";
      public Stats()
      {

public Object GetVariable(string name)
      {
         string results = "";

         
         if(name == "cpu stats")
         {
            if(cpustats == "")
               RefreshCpuStats();
            results = cpustats;
         }
         else if(name == "os stats")
         {
            if(osstats == "")
               RefreshOsStats();
            results = osstats;
         }
         else if(name == "disk stats")
         {
            if(diskstats == "")
               RefreshDiskStats();
            results = diskstats;
         }

         return results;         
      }
Attachments
xLobby Variable Setup snippet.txt
(661 Bytes) Downloaded 257 times
lpg
 
Posts: 296
Joined: Thu Apr 14, 2005 8:17 pm
Location: Chicago

Re: How to send a variable from XL TO a plugin

Postby WannaTheater on Sat Oct 10, 2009 10:39 pm

DOH... thanks for all the help, but I believe i made a really stupid mistake.....
I forgot the keyword "variable" when sending the parameter in to the plugin.

So for my previous example, pretend I execute the command (from withing XL) "save to variable," and make the Information field "HITHERE" and the set "Variable (Location)" to myVariable.

When I call the function in the plugin, the syntax is %variable>myVariable% ... this will send the string "HITHERE" into the plugin. Before I was trying to send in %myVariable%.
WannaTheater
 
Posts: 235
Joined: Thu Aug 24, 2006 11:35 am
Location: Florida