I'm importing an old (7.x) DLL to 17.0 and running into some problems with user commands returning a string. We used to write functions like
- visible double DLL_GetDateTimeString( FLEXSIMINTERFACE )
- {
- stringreturn( "Hello world!" );
- return 0;
- }
but that does not seem to work anymore. The documentation states that as of FlexSim 2016 one can "simply" return a string from the user command, but I tried a couple of options such as
- visible std::string DLL_GetDateTimeString( FLEXSIMINTERFACE )
- {
- return std::string("Hello world!");
- }
and
- visible char* DLL_GetDateTimeString( FLEXSIMINTERFACE )
- {
- std::string result = "Hello world!";
- return apchar( result );
- }
or
- visible const char* DLL_GetDateTimeString( FLEXSIMINTERFACE )
- {
- std::string result = "Hello world!";
- return result.c_str();
- }
but they break the stack or give me nonsense output, respectively.
Could you provide an example of how to return strings from a DLL function in version 2017?