converting std::string to OPERX

Oct 2, 2012 at 8:44 PM

Hi Keith,

 

 is there a way to convert a std::string to a OPERX ? If so can you please ponit out how to do it.

Best

 

Coordinator
Oct 2, 2012 at 9:02 PM

std::string s("a string");
OPER o(s.c_str()); // or o(s.c_str(), s.length()) to avoid a call to strlen

std::wstring ws("a wide string");
OPER12 wo(ws.c_str());

Version independent:

// uncomment for Excel 2007 or above
// #define EXCEL12
xll::traits<XLOPERX>::xstring xs(_T("wide if EXCEL12 is defined, otherwise not"));
OPERX xo(xs.c_str());

Oct 3, 2012 at 2:09 PM

thank you very much Keith, since i already had some function return a string which i wanted to convert to OPERX i used the following code to go from string to wstring. And then i followed your presecription.

 

 std::wstring StringToWString(const std::string& s)
 {
 std::wstring temp(s.length(),L' ');
 std::copy(s.begin(), s.end(), temp.begin());
 return temp;
 }


 std::string WStringToString(const std::wstring& s)
 {
 std::string temp(s.length(), ' ');
 std::copy(s.begin(), s.end(), temp.begin());
 return temp;
 }

best

 

Coordinator
Oct 3, 2012 at 2:14 PM

That can work, but the Windows way of doing things is http://xll.codeplex.com/SourceControl/changeset/view/16811#144055

Oct 3, 2012 at 9:30 PM

wow!! you really are an expert and already thought about all the possible issues that may arise.

Thanks very much i did not realize such a solution already exists in you utility directory.

on a different note. does the addin not work in 64 bit machines ?

the code compiles okay in visual studio express 2010 in the win32 configuation.

but when i open it up in excel i get the "cannot open in DOS" error.

the same code works perfectly okay in 32bit machine.

is there some flag i can change to make it work or fundamentally something is different ?

 

Best

 

Coordinator
Oct 4, 2012 at 2:43 PM

The open source library works on 64-bit windows with 32-bit Office. If you really need to run things in 64-bit Office I have a version for that, but only for paying customers.

Oct 4, 2012 at 8:16 PM

Ooh, I was suspecting some issues with 64vs32 bit excel. Then I thought I am doing something wrong.

Anyway I am just learning to program with these tools experimenting with them to build user defined function just for the fun of it. And most probably won't be able to afford to spend money, specially in this economy.

But thanks for all your help/comments. I learnt a lot.

Best

On Oct 4, 2012 10:44 AM, "keithalewis" <notifications@codeplex.com> wrote:

From: keithalewis

The open source library works on 64-bit windows with 32-bit Office. If you really need to run things in 64-bit Office I have a version for that, but only for paying customers.

Read the full discussion online.

To add a post to this discussion, reply to this email (xll@discussions.codeplex.com)

To start a new discussion for this project, email xll@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com

Jan 2, 2014 at 9:44 AM
keithalewis wrote:
That can work, but the Windows way of doing things is http://xll.codeplex.com/SourceControl/changeset/view/16811#144055 (https://xll.codeplex.com/workitem/144055)
Dear all,
Happy New Year!
Does anyone know what are the current link for the above reference? Many thanks!
OttoW
Coordinator
Jan 2, 2014 at 10:31 AM
Jan 2, 2014 at 11:51 AM
Many thanks Keith!