Statistics: Posted by martignasse — 13 Apr 2015, 09:43
Statistics: Posted by Blaakk — 05 Apr 2015, 02:58
CODE:
if ((Message->wParam == 1) && (Message->lParam == MSG_CHANGE) && (Message->result == 1)) //received 1 on "enable" input {CODE:
if ((Message->wParam == 1) && (Message->lParam == MSG_CHANGE)) { if (sdkGetEvtData(m_enable) == 1){Statistics: Posted by oli_lab — 12 Jul 2013, 01:53
CODE:
m_textNew = sdkGetEvtPChar(m_textInput); // str.push_back((char) m_textNew); sdkSetEvtPChar(m_textOutput, (AinsiCharPtr) (str.c_str())); //sdkSetEvtPChar(m_textOutput, m_textNew);m_textNew is a char pointer, and you add it to str as a char, that's the problemCODE:
str.push_back((char) m_textNew);CODE:
str.append(m_textNew);Statistics: Posted by martignasse — 11 Jul 2013, 20:54
CODE:
m_textNew = sdkGetEvtPChar(m_textInput); //str.push_back((char) m_textNew);sdkSetEvtPChar(m_textOutput, (AinsiCharPtr) (str.c_str()));//sdkSetEvtPChar(m_textOutput, m_textNew);Statistics: Posted by oli_lab — 11 Jul 2013, 17:42
Statistics: Posted by bsork — 11 Jul 2013, 14:32
Statistics: Posted by martignasse — 11 Jul 2013, 12:34
Statistics: Posted by bsork — 11 Jul 2013, 12:13
using std::string and casting it like that is the way to go.I too have a similar problem, but I was trying to use a std::string variable as a parameter caption. I tried different approaches, and ended up with casting similar to examples in the SDK:
(AinsiCharPtr) (s.c_str())
This compiled without warnings, and the string also looked OK when traced, but the parameter caption was empty.
Statistics: Posted by martignasse — 11 Jul 2013, 11:29
Statistics: Posted by bsork — 11 Jul 2013, 08:31
CODE:
//////////////////////////// retourneur de string/////////////////////////// parameters declarationVar input, dummy, reset : TParameter;Var output : TParameter;var sl1 : UNICODESTRING;var sl2 : UNICODESTRING;var size : integer;// destroyprocedure Destroy;begin sl1.free; sl2.free;end;// initialisation : create parametersprocedure init;begin SetModuleColor($800080+302999); input := createParam('in',ptTextField); SetIsOutPut(input,false); reset:= CreateParam('reset',PtButton); SetIsOutput(reset,false); output := createParam('out',ptTextField); SetIsInPut(output,false); size := createParam('size',ptDataField); SetIsInPut(size,false);end;// Global variables//////////////////////////////// CallBack proc//////////////////////////////Procedure CallBack(n:integer);beginif (n = reset) then begin IF (reset >= 1) THEN sl2 := getStringValue(input);end;if (n = input) then begin sl1 := getStringValue(input); sl2 := sl2 + sl1 end; SetStringValue(output,sl2); SetValue(size,Length(sl2));end;CODE:
void StringFlip::onCallBack(UsineMessage *Message) {if ((Message->wParam == 1) && (Message->lParam == MSG_CHANGE) && (Message->result == 1)) //received 1 on "enable" input{ m_textNew = sdkGetEvtPChar(m_textInput); //std::string str;str.push_back((char)m_textNew);sdkSetEvtPChar(m_textOutput, (AinsiCharPtr) str); // this is not working, no conversion between std::string and AinsiCharPtr}if ((Message->wParam == 2) && (Message->lParam == MSG_CHANGE) && (Message->result == 1)) //received 1 on "reset" input{sdkSetEvtPChar(m_textOutput, "");}}Statistics: Posted by oli_lab — 10 Jul 2013, 23:31
Statistics: Posted by martignasse — 13 Apr 2015, 09:43
Statistics: Posted by Blaakk — 05 Apr 2015, 02:58
CODE:
if ((Message->wParam == 1) && (Message->lParam == MSG_CHANGE) && (Message->result == 1)) //received 1 on "enable" input {CODE:
if ((Message->wParam == 1) && (Message->lParam == MSG_CHANGE)) { if (sdkGetEvtData(m_enable) == 1){Statistics: Posted by oli_lab — 12 Jul 2013, 01:53
CODE:
m_textNew = sdkGetEvtPChar(m_textInput); // str.push_back((char) m_textNew); sdkSetEvtPChar(m_textOutput, (AinsiCharPtr) (str.c_str())); //sdkSetEvtPChar(m_textOutput, m_textNew);m_textNew is a char pointer, and you add it to str as a char, that's the problemCODE:
str.push_back((char) m_textNew);CODE:
str.append(m_textNew);Statistics: Posted by martignasse — 11 Jul 2013, 20:54
CODE:
m_textNew = sdkGetEvtPChar(m_textInput); //str.push_back((char) m_textNew);sdkSetEvtPChar(m_textOutput, (AinsiCharPtr) (str.c_str()));//sdkSetEvtPChar(m_textOutput, m_textNew);Statistics: Posted by oli_lab — 11 Jul 2013, 17:42
Statistics: Posted by bsork — 11 Jul 2013, 14:32
Statistics: Posted by martignasse — 11 Jul 2013, 12:34
Statistics: Posted by bsork — 11 Jul 2013, 12:13
using std::string and casting it like that is the way to go.I too have a similar problem, but I was trying to use a std::string variable as a parameter caption. I tried different approaches, and ended up with casting similar to examples in the SDK:
(AinsiCharPtr) (s.c_str())
This compiled without warnings, and the string also looked OK when traced, but the parameter caption was empty.
Statistics: Posted by martignasse — 11 Jul 2013, 11:29
Statistics: Posted by bsork — 11 Jul 2013, 08:31
CODE:
//////////////////////////// retourneur de string/////////////////////////// parameters declarationVar input, dummy, reset : TParameter;Var output : TParameter;var sl1 : UNICODESTRING;var sl2 : UNICODESTRING;var size : integer;// destroyprocedure Destroy;begin sl1.free; sl2.free;end;// initialisation : create parametersprocedure init;begin SetModuleColor($800080+302999); input := createParam('in',ptTextField); SetIsOutPut(input,false); reset:= CreateParam('reset',PtButton); SetIsOutput(reset,false); output := createParam('out',ptTextField); SetIsInPut(output,false); size := createParam('size',ptDataField); SetIsInPut(size,false);end;// Global variables//////////////////////////////// CallBack proc//////////////////////////////Procedure CallBack(n:integer);beginif (n = reset) then begin IF (reset >= 1) THEN sl2 := getStringValue(input);end;if (n = input) then begin sl1 := getStringValue(input); sl2 := sl2 + sl1 end; SetStringValue(output,sl2); SetValue(size,Length(sl2));end;CODE:
void StringFlip::onCallBack(UsineMessage *Message) {if ((Message->wParam == 1) && (Message->lParam == MSG_CHANGE) && (Message->result == 1)) //received 1 on "enable" input{ m_textNew = sdkGetEvtPChar(m_textInput); //std::string str;str.push_back((char)m_textNew);sdkSetEvtPChar(m_textOutput, (AinsiCharPtr) str); // this is not working, no conversion between std::string and AinsiCharPtr}if ((Message->wParam == 2) && (Message->lParam == MSG_CHANGE) && (Message->result == 1)) //received 1 on "reset" input{sdkSetEvtPChar(m_textOutput, "");}}Statistics: Posted by oli_lab — 10 Jul 2013, 23:31