Hi everyone,
Well I'll use scripts to solve my problem posted on my previous thread (KY data S5) and I'm basically using the code PeterW showed me.
For those who didn't check my previous thread what I have is a word on S5 that consists on two bytes, each one of them represents something for me, so I want to display them separatelly on a panel, I'm building the proyect for the panel on WinCC Flex. So I'm dividing the word with a code PeterW showed me. I already tryed a lot of things to get the two bytes and this one seems to be the best way (and also the only one...)
But I'm pretty new to this scripts stuff so I hope someone can guide me, here is what I have:
I added a new script and called it "kydata", the type is "Sub" and the Parameters it have are V, H and L.
The code is like this (and it's all that appears on the Script window):
If (V > 255) Then H = (V/255) : L = V - (H*256)
Else H = 0 : L = V
End If
So far I get this error when I check for errors:
* Expected "End" in line 9, Column 1 (that is the line of the Else)
I also doubt the division will give me only the above 0 value (like if the division is 5/3 and the result is 1.6667 I will only need the 1).
Know I'm planning on, when I enter a screen where I need this, on the "Load" action of the "Event" properties I will configure the script and the tags for H, V and L.
How I'm doing so far???
Can anyone help me with my questions and so far errors please
Thanks in advance
Juan
Well I'll use scripts to solve my problem posted on my previous thread (KY data S5) and I'm basically using the code PeterW showed me.
For those who didn't check my previous thread what I have is a word on S5 that consists on two bytes, each one of them represents something for me, so I want to display them separatelly on a panel, I'm building the proyect for the panel on WinCC Flex. So I'm dividing the word with a code PeterW showed me. I already tryed a lot of things to get the two bytes and this one seems to be the best way (and also the only one...)
But I'm pretty new to this scripts stuff so I hope someone can guide me, here is what I have:
I added a new script and called it "kydata", the type is "Sub" and the Parameters it have are V, H and L.
The code is like this (and it's all that appears on the Script window):
If (V > 255) Then H = (V/255) : L = V - (H*256)
Else H = 0 : L = V
End If
So far I get this error when I check for errors:
* Expected "End" in line 9, Column 1 (that is the line of the Else)
I also doubt the division will give me only the above 0 value (like if the division is 5/3 and the result is 1.6667 I will only need the 1).
Know I'm planning on, when I enter a screen where I need this, on the "Load" action of the "Event" properties I will configure the script and the tags for H, V and L.
How I'm doing so far???
Can anyone help me with my questions and so far errors please
Thanks in advance
Juan