Switch to desktop version  
How to translate a tag into a BCD - Printable Version

+- Ewon Technical Forum (https://techforum.ewon.biz)
+-- Forum: Development (https://techforum.ewon.biz/forum-50.html)
+--- Forum: BASIC Script (https://techforum.ewon.biz/forum-52.html)
+--- Thread: How to translate a tag into a BCD (/thread-167.html)



How to translate a tag into a BCD - Jean-Yves - 07-11-2016

It could happen that the value read by the eWOn is BCD (Binary Coded Decimal) and that you're not able to read it correctly because the eWON displays only the word value. 

Example of this script: The word value is 28804 but it must be displayed in BCD and that would be 7084


  2016-11-07_15h50_50.png (Size: 53,12 KB / Downloads: 42)


Code:
i%=28804
B1%#0 = i%#0
B1%#1 = i%#1
B1%#2 = i%#2
B1%#3 = i%#3

B2%#0 = i%#4
B2%#1 = i%#5
B2%#2 = i%#6
B2%#3 = i%#7

B3%#0 = i%#8
B3%#1 = i%#9
B3%#2 = i%#10
B3%#3 = i%#11

B4%#0 = i%#12
B4%#1 = i%#13
B4%#2 = i%#14
B4%#3 = i%#15

A% = B4% * 1000 + B3% * 100 + B2% * 10 + B1%
Print A%