Question

In analogy with C# server scripting for ASP.NET:

<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
<!DOCTYPE html><html>
<head runat="server">
    <meta name="viewport" content="width=device-width" />
    <title></title>
</head>
<body>
    <% Response.Write("Hello!"); %>
    <div></div>
</body>
</html>

I am attempting to achieve the same using Visual COBOL from Micro Focus. My attempt has failed:

<%@ Page Language="COBOL" Inherits="System.Web.Mvc.ViewPage" %>
<!DOCTYPE html><html>
<head runat="server">
    <meta name="viewport" content="width=device-width" />
    <title></title>
</head>
<body>
    <% invoke Response::"Write"("Hello!") %>
    <div></div>
</body>
</html>

I get the following error, can someone please advise what I am doing wrong?

Compiler Error Message: COBCH0012: Operand Response is not declared

Was it helpful?

Solution

I've been able to find the solution. What we have here are two problems, first is the "Response" is a property of page and page is what we are in the script ("this" in C#). The equivalent in Visual COBOL is "self". Second, there is a problem with the Write, the double quotes do not appear to be necessary.

The following syntax does work and is your hello world for this scenario (which I could not find in the documentation):

<%@ Page Language="COBOL" Inherits="System.Web.Mvc.ViewPage" %>
<!DOCTYPE html><html>
<head runat="server">
        <meta name="viewport" content="width=device-width" />
    <title></title>
</head>
<body>
    <% 
        INVOKE self::Response::Write("<h1>Hello World!</H1>") 
    %>
    <div></div>
</body>
</html>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top