在结构化文本中向字节添加1个
我正在尝试实现以下逻辑:
如果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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信错误是告诉您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.