help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-glpk] VBA/dll for Excel


From: Andrew Makhorin
Subject: Re: [Help-glpk] VBA/dll for Excel
Date: Tue, 18 Mar 2008 20:23:09 +0300

> I produced a DLL as well by adding __stdcall __export to the right
> function calls.  [BTW, I'm using the free Turbo C++ compiler from
> Borland.]

> BUT, I cannot seem to get the callback function for "glp_term_hook" to
> properly work.  Before I begin to setup the problem, I use very similar
> VBA code to what the Version 10 of the Informatiks software uses:

>   Const MAXMSG as long = 500
>   Private ActMsg as long

>   Private Messages(MAXMSG) as string

>   Public sub INIT_GLPK()
>     Dim info as long

>     info = 0
>     glp_term_hook AddressOf MessageHandler, info
>     ActMsg = 0
>   end sub

> and

>   public function MessageHandler(ByVal info As Long, ByVal msg As Long)
> As Long
>     Dim l As Long
>     Dim Err_Message As String

>     On Error Resume Next

>     If ActMsg < MAXMSG Then
>         ActMsg = ActMsg + 1
>     End If
>     l = lstrlen(msg)
>     Err_Message = Space$(l + 1)
>     lstrcpy Err_Message, msg
>     Err_Message = Left(Err_Message, l)
>     Messages(ActMsg) = Err_Message

>     MessageHandler = 1
>   End Function

> However, when the "xputs" function in GLPK tries to return, the code
> bombs.  The "xputs" does call the "MessageHandler", and it seems to pass
> in the correct string, and xputs does see the correct return.  I believe
> that somehow the stack gets messed up a bit, but I haven't figured out
> any workaround.

> Any ideas on how to successfully invoke the call-back function for the
> terminal hook?

In glpk 4.27 all terminal output goes thru the internal routine
xputc (see file glplib05.c), which outputs a single character; so
may be it would be easier simply replace it by your own routine?





reply via email to

[Prev in Thread] Current Thread [Next in Thread]