TPoly
asked on
Some error with datatype
hi all,
i had downloaded the mapirule.cpp from the msdn site to intercept an incoming SMS..
i also downloaded a SendSms codes from : http://www.codeproject.com/ce/SMS_CEMPI.asp.
to send sms.
i also downloaded a string tokeniser from : http://www.codeproject.com/cpp/stringtok.asp
i had edited the codes inside the mapirule.ccp
===start codes edited===
if (wcsstr(pspvEmail->Value.l pszW, L"98494778") != NULL)
{
MessageBeep(MB_ICONASTERIS K);
MessageBox(NULL, pspvSubject->Value.lpszW, pspvEmail->Value.lpszW, MB_OK);
//HANDLE hFile = CreateFile(_T("\\My Documents\\Personal\\jobs. txt"),GENE RIC_WRITE, FILE_SHARE_READ,NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
HANDLE hFile;
const TCHAR* filename = TEXT("\\My Documents\\Personal\\jobs. txt"); // Name of file to be written
const TCHAR* file_contents = pspvSubject->Value.lpszW; // String to be written to file
TCHAR message[255]; // String to be displayed in message box
//DWORD btw;
DWORD bytesWritten;
string show="";
string in_file="";
//The Results Vector
vector<string> oResult;
//Call Tokeniker
in_file=file_contents;
CTokenizer<CIsComma>::Toke nize(oResu lt, in_file, CIsComma());
//Display Results
for(int i=0; i<oResult.size(); i++)
show+=oResult[i]+"TOK";
MessageBox(NULL,show, TEXT("????"), MB_OK);
// Open existing file or create it if it does not exist
hFile = CreateFile(filename, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE)
MessageBox(NULL,TEXT("Coul dn't create the file!"), TEXT("Create File ERROR"), MB_OK);
else
{
wsprintf(message, TEXT("%s"), file_contents);
//btw = wcslen(message)*sizeof(TCH AR);
// Write a string to the file
if (WriteFile(hFile, message ,wcslen(message)*sizeof(TC HAR) , &bytesWritten, NULL)!=0)
{
//wsprintf(message, TEXT("Success - String %s written to file %s."), file_contents, filename);
wsprintf(message, TEXT("%s"), file_contents);
}
else
{
wsprintf(message, TEXT("Error writing to file: %d"), GetLastError());
}
// Display the message indicating the result
MessageBox(NULL, message, TEXT("Result"), MB_OK);
// Close file handle
CloseHandle(hFile);
}
// Delete the message and mark it as handled so it won't show up in Inbox
hr = DeleteMessage(pMsgStore, pMsg, cbMsg, lpMsg, cbDestFolder, lpDestFolder, pulEventType, pHandled);
DoSendMessage(_T("hhhh"), (LPCTSTR)pspvEmail->Value. lpszA, _T("Ack:ECS/CQY/B2/PEU03A" ));
//DoSendMessage(_T("hhhh") , _T("97665982"), _T("Ack:ECS/CQY/B2/PEU03A" ));
}
===end of codes edited==
however i am getting some error when i combine e three files together as a common workspace (mapirule.vcw that contains the maipule project files)
below are the error i got..
===start of error===
Compiling...
mapirule.cpp
c:\documents and settings\tp\desktop\projfi les\mapiru le(20-9)\t okenizer.h (29) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
c:\documents and settings\tp\desktop\projfi les\mapiru le(20-9)\m apirule.cp p(634) : error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'const unsigned short *' (or there is no acceptable conversion)
c:\documents and settings\tp\desktop\projfi les\mapiru le(20-9)\m apirule.cp p(640) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'class std::basic_string<char,str uct std::char_traits<char>,cla ss std::allocator<char> >' to 'const unsign
===end of error ===
any help will be greatly appreciated..
i need some help urgently..
i had downloaded the mapirule.cpp from the msdn site to intercept an incoming SMS..
i also downloaded a SendSms codes from : http://www.codeproject.com/ce/SMS_CEMPI.asp.
to send sms.
i also downloaded a string tokeniser from : http://www.codeproject.com/cpp/stringtok.asp
i had edited the codes inside the mapirule.ccp
===start codes edited===
if (wcsstr(pspvEmail->Value.l
{
MessageBeep(MB_ICONASTERIS
MessageBox(NULL, pspvSubject->Value.lpszW, pspvEmail->Value.lpszW, MB_OK);
//HANDLE hFile = CreateFile(_T("\\My Documents\\Personal\\jobs.
HANDLE hFile;
const TCHAR* filename = TEXT("\\My Documents\\Personal\\jobs.
const TCHAR* file_contents = pspvSubject->Value.lpszW; // String to be written to file
TCHAR message[255]; // String to be displayed in message box
//DWORD btw;
DWORD bytesWritten;
string show="";
string in_file="";
//The Results Vector
vector<string> oResult;
//Call Tokeniker
in_file=file_contents;
CTokenizer<CIsComma>::Toke
//Display Results
for(int i=0; i<oResult.size(); i++)
show+=oResult[i]+"TOK";
MessageBox(NULL,show, TEXT("????"), MB_OK);
// Open existing file or create it if it does not exist
hFile = CreateFile(filename, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE)
MessageBox(NULL,TEXT("Coul
else
{
wsprintf(message, TEXT("%s"), file_contents);
//btw = wcslen(message)*sizeof(TCH
// Write a string to the file
if (WriteFile(hFile, message ,wcslen(message)*sizeof(TC
{
//wsprintf(message, TEXT("Success - String %s written to file %s."), file_contents, filename);
wsprintf(message, TEXT("%s"), file_contents);
}
else
{
wsprintf(message, TEXT("Error writing to file: %d"), GetLastError());
}
// Display the message indicating the result
MessageBox(NULL, message, TEXT("Result"), MB_OK);
// Close file handle
CloseHandle(hFile);
}
// Delete the message and mark it as handled so it won't show up in Inbox
hr = DeleteMessage(pMsgStore, pMsg, cbMsg, lpMsg, cbDestFolder, lpDestFolder, pulEventType, pHandled);
DoSendMessage(_T("hhhh"), (LPCTSTR)pspvEmail->Value.
//DoSendMessage(_T("hhhh")
}
===end of codes edited==
however i am getting some error when i combine e three files together as a common workspace (mapirule.vcw that contains the maipule project files)
below are the error i got..
===start of error===
Compiling...
mapirule.cpp
c:\documents and settings\tp\desktop\projfi
c:\documents and settings\tp\desktop\projfi
c:\documents and settings\tp\desktop\projfi
===end of error ===
any help will be greatly appreciated..
i need some help urgently..
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
OK, I looked up CTokenizer on CodeProject. It does not handle wstring's, so your only option is to go back to string's and get rid of the _UNICODE. Otherwise, you have to dump or rewrite CTokenizer.
ASKER
Actually I need to use unicode.
Do you know of any other tokenizer that handles wstrings?
Do you know of any other tokenizer that handles wstrings?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
so your CTokenizerW class change with the Tokenizer.h 's class CTokenizer is it?
and
======
Your code would looklike this:
wstring show=L"";
wstring in_file=L"";
//The Results Vector
vector<wstring> oResult;
//Call Tokeniker
in_file=file_contents;
CTokenizerW::Tokenize(oRes ult, in_file, (wchar_t)',');
//Display Results
for(int i=0; i<oResult.size(); i++)
show+=oResult[i]+L"TOK";
=========
jus edit in the mapirule.cpp?
and
======
Your code would looklike this:
wstring show=L"";
wstring in_file=L"";
//The Results Vector
vector<wstring> oResult;
//Call Tokeniker
in_file=file_contents;
CTokenizerW::Tokenize(oRes
//Display Results
for(int i=0; i<oResult.size(); i++)
show+=oResult[i]+L"TOK";
=========
jus edit in the mapirule.cpp?
ASKER
To add to my last post:
I am using eMbedded Visual C++ for this project, does it matter?
I am using eMbedded Visual C++ for this project, does it matter?
ASKER
==new error===
Compiling...
mapirule.cpp
c:\program files\windows ce tools\wce420\pocket pc 2003\include\armv4\xstring (724) : warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify -GX
c:\program files\windows ce tools\wce420\pocket pc 2003\include\armv4\xstring (720) : while compiling class-template member function 'void __cdecl std::basic_string<char,str uct std::char_traits<char>,cla ss std::allocator<char> >::_Copy(unsign
ed int)'
c:\program files\windows ce tools\wce420\pocket pc 2003\include\armv4\xstring (724) : warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify -GX
c:\program files\windows ce tools\wce420\pocket pc 2003\include\armv4\xstring (720) : while compiling class-template member function 'void __cdecl std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<u
nsigned short> >::_Copy(unsigned int)'
mapirule.obj - 0 error(s), 2 warning(s)
===end of error===
Compiling...
mapirule.cpp
c:\program files\windows ce tools\wce420\pocket pc 2003\include\armv4\xstring
c:\program files\windows ce tools\wce420\pocket pc 2003\include\armv4\xstring
ed int)'
c:\program files\windows ce tools\wce420\pocket pc 2003\include\armv4\xstring
c:\program files\windows ce tools\wce420\pocket pc 2003\include\armv4\xstring
nsigned short> >::_Copy(unsigned int)'
mapirule.obj - 0 error(s), 2 warning(s)
===end of error===
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I've edited my code using method 2.
But there are still some problems.
The boolean warning is solved.
=========edited code=========
const TCHAR* filename = TEXT("\\My Documents\\Personal\\jobs.
const TCHAR* file_contents = pspvSubject->Value.lpszW; // String to be written to file
TCHAR message[255]; // String to be displayed in message box
//DWORD btw;
DWORD bytesWritten;
wstring show="";
wstring in_file="";
//The Results Vector
vector<string> oResult;
//Call Tokeniker
in_file=file_contents;
CTokenizer<CIsComma>::Toke
//Display Results
for(int i=0; i<oResult.size(); i++)
show+=oResult[i]+"TOK";
MessageBox(NULL,show.c_str
=========edited code=========
++++++++++errors++++++++++
Compiling...
mapirule.cpp
c:\documents and settings\tp\desktop\projfi
No constructor could take the source type, or constructor overload resolution was ambiguous
c:\documents and settings\tp\desktop\projfi
No constructor could take the source type, or constructor overload resolution was ambiguous
c:\documents and settings\tp\desktop\projfi
Reason: cannot convert from 'class std::basic_string<unsigned
No constructor could take the source type, or constructor overload resolution was ambiguous
c:\documents and settings\tp\desktop\projfi
Error executing clarm.exe.
mapirule.obj - 4 error(s), 0 warning(s)
++++++++++errors++++++++++