ArrayArrayArrayArrayArray BrainModular BrainModular Users Forum 2010-03-23T16:23:22+02:00 https://brainmodular.org/forums/app.php/feed/topic/1856 2010-03-23T16:23:22+02:00 2010-03-23T16:23:22+02:00 https://brainmodular.org/forums/viewtopic.php?t=1856&p=12856#p12856 <![CDATA[PCHAR question]]> Statistics: Posted by anbd — 23 Mar 2010, 15:23


]]>
2010-02-06T14:04:02+02:00 2010-02-06T14:04:02+02:00 https://brainmodular.org/forums/viewtopic.php?t=1856&p=11453#p11453 <![CDATA[PCHAR question]]> Thanks!

Statistics: Posted by Gizzeta — 06 Feb 2010, 13:04


]]>
2010-01-20T16:51:21+02:00 2010-01-20T16:51:21+02:00 https://brainmodular.org/forums/viewtopic.php?t=1856&p=11259#p11259 <![CDATA[PCHAR question]]>

in yourmodule.h

add includes

CODE:

#include <string>#include <vector>
and a vector in your module class

CODE:

class TYourModule &#58; public TUserModule&#123;    ...    std&#58;&#58;vector<std&#58;&#58;string> m_vectOutCaptions;    ...&#125;
in yourmodule.cpp

add includes and namespace use

CODE:

#include <string>#include <sstream>#include <vector>using namespace std;
and in GetParamInfo()

CODE:

void GetParamInfo &#40;void* pModule,int n, TParamInfo* pParamInfo&#41;&#123;    // make convenient pointer to the module    TYourModule* pYourModule = &#40;&#40;TYourModule*&#41;pModule&#41;;            // the param name    stringstream Stream;     Stream << &#40;n + 1&#41;;    pYourModule ->m_vectOutCaptions.push_back&#40;string&#40;"Out "&#41; + Stream.str&#40;&#41;&#41;;    if&#40;n < NUM_OF_OUT&#41;    &#123;                pParamInfo->ParamType   = ptArray;        pParamInfo->Caption     = &#40;PCHAR&#41;&#40;pYourModule ->m_vectOutCaptions&#91;n&#93;.c_str&#40;&#41;&#41;;        pParamInfo->IsInput     = false;        pParamInfo->IsOutput    = true;    &#125;&#125;

Statistics: Posted by martignasse — 20 Jan 2010, 15:51


]]>
2010-01-20T14:25:01+02:00 2010-01-20T14:25:01+02:00 https://brainmodular.org/forums/viewtopic.php?t=1856&p=11258#p11258 <![CDATA[PCHAR question]]>
PCHAR is a plain old pointer to char (char*)

so you can do something like this :

in your module class member definition

CODE:

PCHAR OutNames&#91;NUM_OF_OUT&#93;;
in your module constructor

CODE:

for &#40;int n=0;  n < NUM_OF_OUT; n++&#41;&#123;     OutNames&#91;n&#93; = new char&#91;STRING_BUFF_SIZE&#93;;    sprintf_s&#40; OutNames&#91;n&#93;, STRING_BUFF_SIZE, "Out%i", &#40;n +1&#41;&#41;;&#125;
in GetParamInfo

CODE:

void GetParamInfo &#40;void* pModule,int n, TParamInfo* pParamInfo&#41;&#123;if&#40;n < NUM_OF_OUT&#41;&#123;                pParamInfo->ParamType   = ptArray;        pParamInfo->Caption     = &#40;&#40;YourModule*&#41;pModule&#41;->OutNames&#91;n&#93;;        pParamInfo->IsInput     = false;        pParamInfo->IsOutput    = true;&#125;&#125;
in your module destructor

CODE:

for &#40;int n=0;  n < NUM_OF_OUT; n++&#41;&#123;            if &#40;OutNames&#91;n&#93; != NULL&#41;    &#123;        delete&#91;&#93; OutNames&#91;n&#93;;    &#125;&#125;
not tested, but it should do the trick

Statistics: Posted by martignasse — 20 Jan 2010, 13:25


]]>
2010-01-20T01:59:56+02:00 2010-01-20T01:59:56+02:00 https://brainmodular.org/forums/viewtopic.php?t=1856&p=11255#p11255 <![CDATA[PCHAR question]]> I would like to do an object whit N out.
To do this I define the number of output in the .h like this

CODE:

#define NUM_OF_OUT 24
then I allocate an array of TEVT*

CODE:

TEVT*pOut&#91;NUM_OF_OUT&#93;;
in the .cpp I write

CODE:

void GetParamInfo &#40;void* pModule,int n, TParamInfo* pParamInfo&#41; &#123;if&#40;n < NUM_OF_OUT&#41;&#123;pParamInfo->ParamType= ptArray;pParamInfo->Caption= "Out";pParamInfo->IsInput= false;pParamInfo->IsOutput= true;&#125;
and

CODE:

void SetEventAddress &#40;void* pModule, int n, TEVT* pEvent&#41; &#123;TMyModule* pMyModule = &#40;&#40;TMyModule*&#41;pModule&#41;;if&#40;n < NUM_OF_OUT&#41;&#123;pMyModule->pOut&#91;n&#93;   = pEvent;&#125;
it works, no problem.

Now I would like to change the Caption of each out like this: Out1, Out2, ..., Out24.
How can I do it?
pParamInfo->Caption is a PCHAR type, how can I manipulate a string like this?

Thanks for help

Statistics: Posted by Gizzeta — 20 Jan 2010, 00:59


]]>
BrainModular BrainModular Users Forum 2010-03-23T16:23:22+02:00 https://brainmodular.org/forums/app.php/feed/topic/1856 2010-03-23T16:23:22+02:00 2010-03-23T16:23:22+02:00 https://brainmodular.org/forums/viewtopic.php?t=1856&p=12856#p12856 <![CDATA[PCHAR question]]> Statistics: Posted by anbd — 23 Mar 2010, 15:23


]]>
2010-02-06T14:04:02+02:00 2010-02-06T14:04:02+02:00 https://brainmodular.org/forums/viewtopic.php?t=1856&p=11453#p11453 <![CDATA[PCHAR question]]> Thanks!

Statistics: Posted by Gizzeta — 06 Feb 2010, 13:04


]]>
2010-01-20T16:51:21+02:00 2010-01-20T16:51:21+02:00 https://brainmodular.org/forums/viewtopic.php?t=1856&p=11259#p11259 <![CDATA[PCHAR question]]>

in yourmodule.h

add includes

CODE:

#include <string>#include <vector>
and a vector in your module class

CODE:

class TYourModule &#58; public TUserModule&#123;    ...    std&#58;&#58;vector<std&#58;&#58;string> m_vectOutCaptions;    ...&#125;
in yourmodule.cpp

add includes and namespace use

CODE:

#include <string>#include <sstream>#include <vector>using namespace std;
and in GetParamInfo()

CODE:

void GetParamInfo &#40;void* pModule,int n, TParamInfo* pParamInfo&#41;&#123;    // make convenient pointer to the module    TYourModule* pYourModule = &#40;&#40;TYourModule*&#41;pModule&#41;;            // the param name    stringstream Stream;     Stream << &#40;n + 1&#41;;    pYourModule ->m_vectOutCaptions.push_back&#40;string&#40;"Out "&#41; + Stream.str&#40;&#41;&#41;;    if&#40;n < NUM_OF_OUT&#41;    &#123;                pParamInfo->ParamType   = ptArray;        pParamInfo->Caption     = &#40;PCHAR&#41;&#40;pYourModule ->m_vectOutCaptions&#91;n&#93;.c_str&#40;&#41;&#41;;        pParamInfo->IsInput     = false;        pParamInfo->IsOutput    = true;    &#125;&#125;

Statistics: Posted by martignasse — 20 Jan 2010, 15:51


]]>
2010-01-20T14:25:01+02:00 2010-01-20T14:25:01+02:00 https://brainmodular.org/forums/viewtopic.php?t=1856&p=11258#p11258 <![CDATA[PCHAR question]]>
PCHAR is a plain old pointer to char (char*)

so you can do something like this :

in your module class member definition

CODE:

PCHAR OutNames&#91;NUM_OF_OUT&#93;;
in your module constructor

CODE:

for &#40;int n=0;  n < NUM_OF_OUT; n++&#41;&#123;     OutNames&#91;n&#93; = new char&#91;STRING_BUFF_SIZE&#93;;    sprintf_s&#40; OutNames&#91;n&#93;, STRING_BUFF_SIZE, "Out%i", &#40;n +1&#41;&#41;;&#125;
in GetParamInfo

CODE:

void GetParamInfo &#40;void* pModule,int n, TParamInfo* pParamInfo&#41;&#123;if&#40;n < NUM_OF_OUT&#41;&#123;                pParamInfo->ParamType   = ptArray;        pParamInfo->Caption     = &#40;&#40;YourModule*&#41;pModule&#41;->OutNames&#91;n&#93;;        pParamInfo->IsInput     = false;        pParamInfo->IsOutput    = true;&#125;&#125;
in your module destructor

CODE:

for &#40;int n=0;  n < NUM_OF_OUT; n++&#41;&#123;            if &#40;OutNames&#91;n&#93; != NULL&#41;    &#123;        delete&#91;&#93; OutNames&#91;n&#93;;    &#125;&#125;
not tested, but it should do the trick

Statistics: Posted by martignasse — 20 Jan 2010, 13:25


]]>
2010-01-20T01:59:56+02:00 2010-01-20T01:59:56+02:00 https://brainmodular.org/forums/viewtopic.php?t=1856&p=11255#p11255 <![CDATA[PCHAR question]]> I would like to do an object whit N out.
To do this I define the number of output in the .h like this

CODE:

#define NUM_OF_OUT 24
then I allocate an array of TEVT*

CODE:

TEVT*pOut&#91;NUM_OF_OUT&#93;;
in the .cpp I write

CODE:

void GetParamInfo &#40;void* pModule,int n, TParamInfo* pParamInfo&#41; &#123;if&#40;n < NUM_OF_OUT&#41;&#123;pParamInfo->ParamType= ptArray;pParamInfo->Caption= "Out";pParamInfo->IsInput= false;pParamInfo->IsOutput= true;&#125;
and

CODE:

void SetEventAddress &#40;void* pModule, int n, TEVT* pEvent&#41; &#123;TMyModule* pMyModule = &#40;&#40;TMyModule*&#41;pModule&#41;;if&#40;n < NUM_OF_OUT&#41;&#123;pMyModule->pOut&#91;n&#93;   = pEvent;&#125;
it works, no problem.

Now I would like to change the Caption of each out like this: Out1, Out2, ..., Out24.
How can I do it?
pParamInfo->Caption is a PCHAR type, how can I manipulate a string like this?

Thanks for help

Statistics: Posted by Gizzeta — 20 Jan 2010, 00:59


]]>