Help with VB to COBOL cpnvert - 105 memory allocation error

[Migrated content. Thread originally posted on 10 August 2011]


A client has a question relating to a VB to COBOL conversion, could I ask for assistance or advise on why the 105 memeory allocation error occurs:


Original text:
Hi I am trying to convert a vb program to cobol and have hit a snag that I do not know how to do it, can you help please. I have attached a test app, I am having trouble converting the following:
Call SetFpcCallback(Addressof FprCallback)

Private Sub SetFprCallback(ByVal lpFunc As Long)
Fpr1.FprCallback = lpfunc
End Sub

I think it is trying to pass the memory address of FprCallback to the sub program Fpr1.

In my Cobol program (Bacfpr.cbl) the relevant section is SET-CALLBACK, when I push the Push Button I get an error 105 Memory allocation error.


invoke Fpr "FprCallback"
using DataBlock-pointer

move FprCallback to FprCallback

* perform AUTO-SNAP



invoke Fpr "CopyCapImage"
using lpBuff
returning anInt


LMain-Process SECTION.
initialize w-validprints
PERFORM LProgram-Initialize
if w-ok = zero
PERFORM LProgram-Body until l-first = 3


I tried to attach the Cobol files but get a server error from the website.
  • Verified Answer


    From what I can tell from the post, the VB code is simply setting a function pointer. So the equivalent COBOL code is to define a PROCEDURE-POINTER, lets call it fprCallbackFunc and you set it by doing something like

    set fprCallbackFunc to entry "the-function-to-point-to"

    (I can't tell from a quick look at the code attached to the incident quite what it is trying to set the callback to)

    and you can then pass it to the code that stores it via

    invoke Fpr "setFprCallBack" using by value fprCallbackFunc

    It should be as simple as that.