Highlighted
Absent Member.
Absent Member.
193 views

[archive] Convert VB code to COBOL

[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
0 Likes
2 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] Convert VB code to COBOL

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.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Convert VB code to COBOL

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.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.