Quick Sign In:  

Forum: VirtualDJ Plugins

Topic: Help with calling plugin functions from vdjScript

This topic is old and might contain outdated or incorrect information.

Hi all, I would like to use POI action markers to call functions in my plugin. My current course is to try and use an effect_command action on the marker, and to call my function from OnParameter

Marker Action:
effect_command 'RevePlugin1' 't'


Declaration:

m_transitionCommand = 'n';

DeclareParameterCommand(&m_transitionCommand, ID_CMD_1, "Command", "CMD", sizeof(&m_transitionCommand));


Usage in OnParameter:

case ID_CMD_1:
if (m_transitionCommand == 't')
{
transition();
}

break;


Function:

void RevesPlugin1::transition()
{
HRESULT hr;
hr = SendCommand("deck 2 play");
}


Unfortunately, it doesn't work, and I haven't had much luck finding helpful documentation. Would some kind soul either help me understand how effect_command and DeclareParameterCommand are supposed to work, or point me toward a better way of calling functions from vdjScript?

Thanks
 

Posted Fri 21 Feb 20 @ 6:25 pm
AdionPRO InfinityCTOMember since 2006
How did you declare m_transitionCommand?
Looking at the use of single quotes ('t' and 'n') it appears that it is defined as a single char, while the DeclareParameterCommand function expects a string to be passed.
So the declaration could be something like
char m_transitionComand[200] for a character array that can hold up to 200 characters.
To check equality of a string, you should further use the strcmp function or similar.
Also make sure to properly initialize the buffer (clear it using memset, or in modern c++ use {} to initialize it on declaration)
 

Posted Fri 21 Feb 20 @ 6:56 pm


Thanks Adion,

Yeah, I had been initializing m_transitionCommand as a single char. This time I tried making it a char array with:

RevePlugin1.h:

#define STRMAX 200
char m_transitionCommand[STRMAX]{};


RevePlugin1.cpp;

DeclareParameterCommand(m_transitionCommand, ID_CMD_1, "Command", "CMD", sizeof(m_transitionCommand));


OnParameter:

case ID_CMD_1:
if (strcmp(m_transitionCommand, "Command1"))
{
transition();
}

break;


Transition Function:

void RevesPlugin1::transition()
{
HRESULT hr;
hr = SendCommand("deck 2 play");
}


POI Marker Action:

effect_command 'RevePlugin1' 'Command1'


The desired behavior continues to elude me.

 

Posted Sat 22 Feb 20 @ 5:05 am
AdionPRO InfinityCTOMember since 2006
Close, but I think you are missing the command index:
effect_command 'RevePlugin1' 1 'Command1'
To send 'Command1' to the first command parameter of RevePlugin1

Edit: also take a closer look to the documentation of strcmp ( http://www.cplusplus.com/reference/cstring/strcmp/ )
It returns 0 if the strings are equal, and now you are checking if it's not 0, so you should add ==0 to check for equality.
 

Posted Sat 22 Feb 20 @ 5:12 am
Thanks again, it works great now.

Could you tell me how the command index works? It seems to be independent of the value passed into the 'int id' parameter of DeclareParameterButton.
 

Posted Sat 22 Feb 20 @ 9:30 am
AdionPRO InfinityCTOMember since 2006
The id just has to be unique.

The index is indeed independent from this and simply follows the order of the declarations. (first is 1, second is 2 etc)
 

Posted Sat 22 Feb 20 @ 10:45 am
Thanks so much for all your swift help! It is much appreciated.
 

Posted Sat 22 Feb 20 @ 1:34 pm


(Old topics and forums are automatically closed)