Link to home
Start Free TrialLog in
Avatar of TPoly
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.lpszW, L"98494778") != NULL)

      {
            MessageBeep(MB_ICONASTERISK);
            MessageBox(NULL, pspvSubject->Value.lpszW, pspvEmail->Value.lpszW, MB_OK);

            //HANDLE hFile = CreateFile(_T("\\My Documents\\Personal\\jobs.txt"),GENERIC_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>::Tokenize(oResult, 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("Couldn't create the file!"), TEXT("Create File ERROR"), MB_OK);
            else
            {
wsprintf(message, TEXT("%s"), file_contents);
//btw = wcslen(message)*sizeof(TCHAR);

                  // Write a string to the file
                  if (WriteFile(hFile, message ,wcslen(message)*sizeof(TCHAR) , &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\projfiles\mapirule(20-9)\tokenizer.h(29) : warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
c:\documents and settings\tp\desktop\projfiles\mapirule(20-9)\mapirule.cpp(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\projfiles\mapirule(20-9)\mapirule.cpp(640) : error C2664: 'MessageBoxW' : cannot convert parameter 2 from 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' to 'const unsign
===end of error ===

any help will be greatly appreciated..
i need some help urgently..
SOLUTION
Avatar of drichards
drichards

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of TPoly
TPoly

ASKER

Thanks for the speedy reply, drichards.

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.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;

            wstring show="";
            wstring in_file="";

            //The Results Vector
            vector<string> oResult;
            //Call Tokeniker
            in_file=file_contents;
            CTokenizer<CIsComma>::Tokenize(oResult, in_file, CIsComma());
            //Display Results
            for(int i=0; i<oResult.size(); i++)
              show+=oResult[i]+"TOK";

                               MessageBox(NULL,show.c_str(), TEXT("????"), MB_OK);
=========edited code=========

++++++++++errors++++++++++++
Compiling...
mapirule.cpp


c:\documents and settings\tp\desktop\projfiles\mapirule(20-9)\mapirule.cpp(628) : error C2440: 'initializing' : cannot convert from 'char [1]' to 'class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >'

No constructor could take the source type, or constructor overload resolution was ambiguous


c:\documents and settings\tp\desktop\projfiles\mapirule(20-9)\mapirule.cpp(629) : error C2440: 'initializing' : cannot convert from 'char [1]' to 'class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >'

No constructor could take the source type, or constructor overload resolution was ambiguous


c:\documents and settings\tp\desktop\projfiles\mapirule(20-9)\mapirule.cpp(635) : error C2664: 'Tokenize' : cannot convert parameter 2 from 'class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >' to 'const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &'
       
Reason: cannot convert from 'class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >' to 'const class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >'
No constructor could take the source type, or constructor overload resolution was ambiguous


c:\documents and settings\tp\desktop\projfiles\mapirule(20-9)\mapirule.cpp(638) : error C2679: binary '+=' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' (or there is no acceptable conversion)


Error executing clarm.exe.


mapirule.obj - 4 error(s), 0 warning(s)
++++++++++errors++++++++++++
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
Avatar of TPoly

ASKER

Actually I need to use unicode.

Do you know of any other tokenizer that handles wstrings?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of TPoly

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(oResult, 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?
Avatar of TPoly

ASKER

To add to my last post:

I am using eMbedded Visual C++ for this project, does it matter?
Avatar of TPoly

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,struct std::char_traits<char>,class 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===
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial