How to output into Excel cell an error message directly from qlxl function call?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to output into Excel cell an error message directly from qlxl function call?

Andrew Kolesnikov
Hello.
I try to return an error message directly from any OPER* function. Usually, in any catch section (at the end of XLL_DEC function description) error message are logged by logError() function. So return value is 0, or #NUM in Excel cell. Is there any way to return an error message during function call, instead of usage retrieveError function (like in QLXL framework by "Display error" option)? I tried to create a local XLOPER variable in catch section, such as:

catch (const std::exception &e) {
    XLOPER returnValue;
    const std::string str = e.what();
    ObjectHandler::scalarToOper(str, returnValue);
    return &returnValue;
}
but of course it doesn't work cause the returnValue variable is local.
Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: How to output into Excel cell an error message directly from qlxl function call?

Eric Ehlers-2
Hello,

On Thu, August 21, 2008 13:40, a.p. wrote:

>
> Hello.
> I try to return an error message directly from any OPER* function. Usually,
> in any catch section (at the end of XLL_DEC function description) error
> message are logged by logError() function. So return value is 0, or #NUM in
> Excel cell. Is there any way to return an error message during function
> call, instead of usage retrieveError function (like in QLXL framework by
> "Display error" option)? I tried to create a local XLOPER variable in catch
> section, such as:
>
> catch (const std::exception &e) {
>     XLOPER returnValue;
>     const std::string str = e.what();
>     ObjectHandler::scalarToOper(str, returnValue);
>     return &returnValue;
> }
> but of course it doesn't work cause the returnValue variable is local.
> Thanks.

You just need to declare returnValue as a static variable.

Regards,
Eric

-------------------------
Eric Ehlers
nazcatech sprl | Brussels | http://www.nazcatech.be
Distributed computing for pricing analytics - Use Microsoft Excel as a client
to the Grid


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
QuantLib-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-dev