c++ type conversion between std::string and System::String^

Discussions and Tech Support related to automating the iMacros Browser or Internet Explorer from any scripting and programming language, such as VBS (WSH), VBA, VB, Perl, Delphi, C# or C++.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
andrew
Posts: 1
Joined: Mon Jul 02, 2018 4:57 pm

c++ type conversion between std::string and System::String^

Post by andrew » Mon Jul 02, 2018 6:06 pm

EDIT -- I found the answer here: https://stackoverflow.com/questions/353 ... -stdstring

Hi! I'm trying to write a c++ script that takes an excel (.csv) file as input. For background, I'm on Windows 7, am using the iMacros browser, and am running version 12.0.501.6698.

I can read the input into a std::string and parse that easily, but cannot do the same with System::String^. However, all the iMacros commands don't take std::string as input — they take System::String^. The issue is that I can parse std::string, but can't run iMacros commands with it. On the converse, I can't parse System::String^, but can run iMacros commands with it.

For example: (assume all variables are defined, etc.)

Code: Select all

std::string normalString  = "CODE:URL GOTO=https://www.google.com/"; // creates a normal string
System::String^ clrString = "CODE:URL GOTO=https://www.google.com/"; // creates a clr String

app->iimPlay(normalString,  TIMEOUT); // doesn't compile b/c iimPlay takes System::String as input
app->iimPlay(clrString, TIMEOUT); // works fine

getline(inputFile, normalString); //works fine, getline sets normalString to a line from inputFile
getline(inputFile, clrString); // doesn't compile

clrString = normalString; //also doesn't compile
This is the same for cstrings/char arrays.

Is there a way to convert from std::string/cstring/char array to System::String^? Thanks!
Post Reply