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

标签 asp.net cobol cobol.net

与 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>

我正在尝试使用 Micro Focus 的 Visual COBOL 实现相同的目标。我的尝试失败了:

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

我收到以下错误,有人可以告诉我我做错了什么吗?

Compiler Error Message: COBCH0012: Operand Response is not declared

最佳答案

我已经找到了解决方案。这里有两个问题,第一是“Response”是页面的属性,而页面是我们在脚本中的内容(C# 中的“this”)。 Visual COBOL 中的对应词是“self”。其次,Write有问题,双引号似乎没有必要。

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

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

关于Visual COBOL 中的 ASP.NET 服务器端脚本编写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21631353/

相关文章:

c# - 如何使下拉列表在下拉列表的顶部而不是底部显示选定的值?

c# - 如何从访问者那里获取 IP 地址(如果在代理后面也是如此)

cobol - 有没有办法让执行不结束(比如无限循环)?

cobol - 我在使用 Cobol 处理表格时遇到问题

c# - HttpContext.User.Identity.Name 在 Azure 服务器上不起作用

c# - 初始化从“编辑”、“选择性粘贴”、“将 XML 粘贴为类”获得的 xml 类

ssh - IBM S/390 大型机 COBOL 源代码

unicode - IBM 大型机上 Shift-JIS 的日语 COBOL 代码;传输到PC后如何表示?

cobol - 从压缩十进制字段中分割数字