在结构化文本中向字节添加1个

发布于 2025-02-07 17:52:54 字数 319 浏览 0 评论 0原文

我正在尝试实现以下逻辑:

如果BCC = STX或 bcc = cr,然后bcc:= +1(增量 1)。

BCC是一个字节,如果以上条件为真,我正在尝试将其递增1。

我的代码是:

如果message_byte [11] = 16#0d或message_byte [11] = 16#02然后 message_byte [11]:= message_byte [11] + to_byte(1); end_if

message_byte是一个字节的数组,我想访问特定的字节。但是,当我说无法添加时,这给了我一个错误。

任何帮助都将受到赞赏

I'm trying to implement the logic below:

if bcc = STX or
bcc = CR, then bcc := +1 (increment
of 1).

bcc is a byte and i'm trying to increment it by 1 if this condition above is true.

my code is:

IF message_byte[11] = 16#0D OR message_byte[11] = 16#02 THEN
message_byte[11] := message_byte[11] + TO_BYTE(1);
END_IF

where message_byte is an array of bytes and I want to access a specific one. However, it gives me an error when saying it can't be added.

any help is appreciated

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白色秋天 2025-02-14 17:52:54

我相信错误是告诉您Message_byte [11](添加的左操作者)不是类型的字节,因此编译器无法弄清楚如何向其添加字节 - 如DWPESSOA所说。我也不知道什么是“字节”的数据类型 - 也许应该是字节。

当您获得这些类型的错误时,请尝试分解任务,然后尝试绝对基础知识 - 只需尝试将1添加到Message_byte [11]。那么解决错误将更容易。

I believe the error is telling you that message_byte[11] (left operant of your addition) is not a type BYTE, so the compiler can’t figure out how to add a BYTE to it - as commented by dwpessoa. I also don’t know what a data type “BYTES” is - maybe that should just be BYTE.

When you get these types of errors, try breaking apart your task and just try the absolute basics - just try adding 1 to message_byte[11]. Then it will be easier to solve the error.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文