代码之家  ›  专栏  ›  技术社区  ›  Mishax

Visual COBOL中的ASP.NET服务器端脚本

  •  2
  • Mishax  · 技术社区  · 12 年前

    与ASP.NET的C#服务器脚本类似:

    <%@ 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>
    

    我正试图使用MicroFocus的VisualCOBOL实现同样的目标。我的尝试失败:

    <%@ 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>
    

    我犯了以下错误,有人能告诉我我做错了什么吗?

    编译器错误消息:COBCH0012:未声明操作数响应

    1 回复  |  直到 9 年前
        1
  •  3
  •   Mishax    12 年前

    我已经找到了解决办法。我们这里有两个问题,首先是“Response”是页面的属性,而页面是我们在脚本中的属性(C#中的“this”)。Visual COBOL中的等效项是“self”。第二,Write有问题,双引号似乎没有必要。

    以下语法确实有效,并且是这个场景的hello世界(我在文档中找不到):

    <%@ 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>