Skip to main content

[archive] Convert VB code to COBOL

  • February 3, 2009
  • 3 replies
  • 0 views

[Migrated content. Thread originally posted on 02 February 2009]

I was hoping someone might be familiar enough with VB code and COBOL code that they could help me write the following VB code in COBOL?

strPostData = strPostData & Chr(AscB(MidB(PostData, lCount, 1))) ' Use MidB to get 1 byte at a timeThis is an example of converting the Post String that is passed through the BeforeNavigate2 event in the IE browser control. It's passed as a Variant. The code above is necessary because the PostData argument contains a SafeArray Bytes. So that code is necessary to retrieve the data.

The article I found this is at http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q256195. There is also some C code there. I'm just trying to accomplish the same thing in AcuCobol. Can anyone help?

Thanks,
Rob

3 replies

[Migrated content. Thread originally posted on 02 February 2009]

I was hoping someone might be familiar enough with VB code and COBOL code that they could help me write the following VB code in COBOL?

strPostData = strPostData & Chr(AscB(MidB(PostData, lCount, 1))) ' Use MidB to get 1 byte at a timeThis is an example of converting the Post String that is passed through the BeforeNavigate2 event in the IE browser control. It's passed as a Variant. The code above is necessary because the PostData argument contains a SafeArray Bytes. So that code is necessary to retrieve the data.

The article I found this is at http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q256195. There is also some C code there. I'm just trying to accomplish the same thing in AcuCobol. Can anyone help?

Thanks,
Rob
Normally, you would just iterate through a safe array, like this:


       01 VARIANT-ARRAY             USAGE HANDLE OF VARIANT OCCURS 3.
       PROCEDURE DIVISION USING VARIANT-COUNT, VARIANT-ARRAY.
       MAIN-LOGIC.
           CALL    "C$GETVARIANT"   USING VARIANT-COUNT WS-COUNT.
           CALL    "C$GETVARIANT"   USING VARIANT-ARRAY(1) WS-CARD.
           CALL    "C$GETVARIANT"   USING VARIANT-ARRAY(2) WS-FLOAT.
           CALL    "C$GETVARIANT"   USING VARIANT-ARRAY(3) WS-STRING.


However, as you can certainly see, the problem here is that we have the unknown, the count...

If you exceed a safearray range, you will get a runtime error claiming bad parameter.

Hm... I think this is really worth an enhancement request, say, enhance c$getvariant to return a result (success or failure) rather than throw an error.

[Migrated content. Thread originally posted on 02 February 2009]

I was hoping someone might be familiar enough with VB code and COBOL code that they could help me write the following VB code in COBOL?

strPostData = strPostData & Chr(AscB(MidB(PostData, lCount, 1))) ' Use MidB to get 1 byte at a timeThis is an example of converting the Post String that is passed through the BeforeNavigate2 event in the IE browser control. It's passed as a Variant. The code above is necessary because the PostData argument contains a SafeArray Bytes. So that code is necessary to retrieve the data.

The article I found this is at http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q256195. There is also some C code there. I'm just trying to accomplish the same thing in AcuCobol. Can anyone help?

Thanks,
Rob
That's bad news Gisle, as we need this capability now. I appreciate the quick response, however, and have requested the enhancement through support. I'll look at tackling this problem using VB.

[Migrated content. Thread originally posted on 02 February 2009]

I was hoping someone might be familiar enough with VB code and COBOL code that they could help me write the following VB code in COBOL?

strPostData = strPostData & Chr(AscB(MidB(PostData, lCount, 1))) ' Use MidB to get 1 byte at a timeThis is an example of converting the Post String that is passed through the BeforeNavigate2 event in the IE browser control. It's passed as a Variant. The code above is necessary because the PostData argument contains a SafeArray Bytes. So that code is necessary to retrieve the data.

The article I found this is at http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q256195. There is also some C code there. I'm just trying to accomplish the same thing in AcuCobol. Can anyone help?

Thanks,
Rob
That's bad news Gisle, as we need this capability now. I appreciate the quick response, however, and have requested the enhancement through support. I'll look at tackling this problem using VB.