Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.

Error in OLE event

Not sure what is going on here but I thought I would ask here first as the error is on an OLE event on your button control.

Event copied from OI 9.4 looks like this
Call ToolBar_OLE_Event(CtrlEntId, EventName)
Return 1

When I run the form and click on the button, the code that I call above seems to execute but then I get an error.

The error occurs in the event, but the fatal runtime error makes no sense. It says
ENG0015: $$$$W_TACTIC*OLE*MAIN_TACTIC,BUTTTON2, line 23 illegal op code 73.

The event only has 2 lines how can it fail on line 23? BTW the line number it fails on seems to vary.

Any ideas? Or do I need to ask this question on the Revelation forum?


  • Can you share the SendMessage code you use to register the button event?
  • Ret_Val = Send_Message(OleCtrlEntId, "QUALIFY_EVENT", "OnClick", 1)
  • Is this an issue with your OLE control, or do I need to re-ask this question on the Revelation forums?
  • Sorry for the delayed response. I think there was a bit of misunderstanding with your question which is why we didn't get back to you sooner. I want to verify something with you. Are you experiencing this problem in OI 9.4 or in OI 10? Also, what happens if you comment out the call to your routine? Does the event handler run without the error?
  • OI10.
    If I comment out the call to the subroutine, the error goes away (but the code I need to run obviously does not execute). If I add the call back in I get the same error or similar, the exact message seems to vary, this time I got
    ENG0015: $$$$W_TACTIC*OLE*MAIN_TACTIC,BUTTTON2, line 1023 illegal op code 57.
  • Since you are able to run the event handler without any issue with your routine commented out, I doubt the problem is with OLE event handling. Rather it seems that something in your ToolBar_OLE_Event routine is causing OI 10 some heartburn. Without seeing the logic in that routine I can't fathom any guesses. You may need to take this to Revelation but my suggestion is to isolate lines of code in your routine first so that you can be very specific (or perhaps it might even point you to your own solution).
  • Just tried again, this time the error is
    ENG0015: $$$$W_TACTIC*OLE*MAIN_TACTIC,BUTTTON2, line 76 illegal op code 73.
  • Do you mean you tried again with your code running or with your code disabled?
  • OK, strange.

    So you are saying the error is in the subroutine being called, but the debugger is reporting the error in the event.
  • Yes, that is what I'm saying. The reason it appears to be in the event is because this isn't a normal runtime error (like a VNAV). Something in your code is causing an op code problem, which causes all kinds of pointer issues within the engine. Thus, identifying the real culprit via the debugger is problematic. You need to isolate the code in your routine. If I had to guess, you are calling a statement in your code that might not have been converted to OI 10 property.
  • If I place an return at the front of the subroutine being called the error goes away.

    If I place a debug at the front of the subroutine being called then step through the subroutine, It all seems to work but at the end of the code as the subroutine returns to the event I see the error.

    So it seems my code is doing something that breaks OI10.

    Problem is this code is doing a lot, detaching and attaching tables, reading data etc.

    This might take some time to track down, ugh...
  • I understand. Been there too many times. Hopefully you can segregate blocks of code to help whittle it down quickly. I normally try to divide my code in half and then keep dividing until I zero in on the culprit.
  • This is really strange. The OLE button event code does nothing except this (it actually does way more, but in this situation that is all it does, one subroutine handles all the OLE buttons).
    If I take the code from that menu event and replace the above line of code, the error still occurs.
    However, if I just use the menu to execute the code and ignore the button bar, I don't see an error. The exact same code is running but I only see the error when called via the OLE event on your control.
    I'll keep you updated.
    Ugh, I hate this...
  • To confirm:
    Code called from menu event works.
    Same exact call from OLE event fails on return
  • I take it then that if you replaced:
    Call ToolBar_OLE_Event(CtrlEntId, EventName)
    You still see the error?
  • Just posted this on the Rev forum

    USing SRPs OLE Button control.

    If I call a piece of code from a menu event on a form, it works.

    If call exact same code from OLE button control on the same form, OI gives an error as it returns from the code into the event. That is the error is reported in the event.

    The error looks like this:
    ENG0015: $$$$W_TACTIC*OLE*MAIN_TACTIC,BUTTTON2, line 23 illegal opcode 73.

    The line number and opcode seem to vary (I just saw an opcode of 57). Note OLE event only has 2 lines a call to the same code called in the menu event and a Return 1, so line number makes no sense.

    The event is qualified like this:
    Ret_Val = Send_Message(OleCtrlEntId, "QUALIFY_EVENT", "OnClick", 1)

    Any ideas anyone?
  • Despite the op code error, does the MENU event handler get called? What happens if you change the Send_Event to Post_Event?
  • No.

    I placed at the very front of ToolBar_OLE_Event the same code as in the menu event followed by a return. So the only code executing in ToolBar_OLE_Event is the same code as in the menu event.

    I just tried this:
    Removed call to ToolBar_OLE_Event in OLE event and replaced it with the same exact code as the menu event has.

    Now when I run the OLE event, OI crashes hard, no error just closes.
  • I removed the send event logic entirely. If both events have the same exact code (they now call a subroutine called Click_Open. The menu works, OLE event as I say above crashes hard, no error, nothing just exits from memory.
  • You are making progress, but Revelation (and SRP) are still looking for a needle in a haystack. So, what does Click_Open do? Have you attempted to isolate the code in that routine?
  • Well, it does all kind of stuff but only fails when called from an OLE event. And it fails badly, a complete crash, now that I have removed the call to a subroutine.

    The code opens a dialog, lets the user makes a few choices, the user presses OK button, it then detaches tables, deletes files, copies files, attaches tables, reads all kind of data from DOS files. Enables and disables menus on an OI form, and probably a heck of a lot more.

    Up until the crash, as best I can tell the called code works.

    I don't think it's something my code is doing. If my code has a problem why would the same code work perfectly from a menu event?
  • Tomorrow I am going to try simplifying the code that is called.
  • Does that same code then close the dialog? Doing that with an ole button crashes more times than not.
  • I don't think it's something my code is doing. If my code has a problem why would the same code work perfectly from a menu event?

    Don't misunderstand me, I'm not faulting your code but something that your code is doing is giving OI 10 some fits. I understand this only occurs during an OLE event. But as you pointed out, it works in OI 9 so this still suggests that something in OI 10 is different enough to cause this problem. So I encourage you to continue simplifying your code until you get to the root of the issue. From there we can better advise you of a solution or work around.
  • The dialog does get closed by the dialog, it calls End_Dialog.

    Is this crash new under OI10, I have not seen it on 9.4.
  • I don't have enough experience with OI 10 to answer your question, but I would encourage you to see if closing the dialog differently prevents the crash. For instance, do you allow the "X" system menu button to exist? If so, what happens if this is used to close the dialog versus End_Dialog?
  • It's not closing the dialog.

    The crash is due to calling Repository('COMPILE' in the code.

    If the code called from the OLE event has a call to Repository('COMPILE' it will crash, the same code called from a menu event does not crash.
  • This seems to confirm that it isn't anything wrong with your code, but something is different in OI 10 where calling this from within an OLE event handler causes problems. I saw your post on the Rev forum, so hopefully that will be enough for Carl to work with and offer some ideas.
  • Jim, another thought...earlier I asked you what happens if you use Post_Event rather than Send_Event. I got the impression that you never tested that because you opted to call your code directly for testing purposes rather than call Send_Event. I would suggest that you restore your code back to the way it was but still change Send_Event to Post_Event and see what happens. The rationale is this: Send_Event forces the event handler to get called immediately and the system waits for it to return. Thus, in this sense there is no difference between using Send_Event and calling Click_Open directly. Post_Event, however, waits for the call stack to be finished and then it calls the event handler. This means the OLE event will have finished running first and then your MENU event handler will execute. This might be enough to avoid the crash.
  • Using Post_Event did not work, the same error occurs.
    Thanks for the suggestion.
    I guess we wait to see what Carl comes up with.
    I think I can code around this by saving both the source code and the compiled code, that would remove the need to compile the code when I load it.
Sign In or Register to comment.