Skip to main content

消息编译指示

消息编译指示生成输出文本,这些文本显示在 消息 编译操作后查看。此外,消息类型 (消息警告,或 错误 ) 可以分配。

插入位置:POU 文本编辑器中的单独行或现有行。

23. 4 种类型的消息编译指示

编译指示

代码片段示例

消息类型

{text <literal> }

{text 'Hallo Allgäu!'}
{text 'Part PLC_PRG has been compiled completely'}

没有类型

输出;定义为字符串字面量 <literal>:

Hallo Allgäu!

Part PLC_PRG has been compiled completely

{info <literal> }

{info 'I01: This is for your information.' }

键入为消息 _cds_icon_info.png

输出:

_cds_icon_info.png I01:This is for your information.

{warning <literal>}

{warning 'W01: This is a warning to you.'}

键入为警告 _cds_icon_warning.png

与属性编译指示不同 'obsolete',你可以在本地为当前位置定义这种警告。

重要

警告语用语 {warning <'warning string'>} 仅允许用于 POU、语句和变量等对象。

输出:

_cds_icon_warning.png C0373: W01: This is a warning to you.

{error <literal>}

{error 'E00: Error has occured.'}

键入为错误 _cds_icon_error.png

输出:

_cds_icon_error.png E00:出现错误。



提示

消息 视图, _cds_icon_error.png 错误_cds_icon_warning.png 警告,以及 _cds_icon_info.png 消息 按钮可用于筛选输出文本。或者你可以使用 下一条消息上一条消息 用于浏览各个消息的命令。

注意 转到来源位置 命令。你可以使用这个命令跳转到源代码中实现编译指示的位置

253. 示例
PROGRAM PLC_PRG
VAR
    iVar : INT; {info 'Info0: This is for your information.'}
    bVar : BOOL;
    arrTest : ARRAY [0..10] OF INT;
END_VAR
{text 'Hello Allgäu!'}

arrTest[iVar] := arrTest[iVar]+1;
{warning 'W01: This is a warning'}
iVar := iVar+1;
{warning 'W02: This is a second warning'}

{text 'Part PLC_PRG has been compiled completely'}

在消息视图中显示:

_cds_img_pragma_message.png