Codesys "mask" digits of the integer

jherbicide

Member
Join Date
Dec 2016
Location
Ankeny IA
Posts
3
How would you "mask" a word/dword/byte to show each significant digit?

For example, for a word that in integer is 12345. I want to mask so I get each individual digit in their own bytes/words:

Integer=12345

digit_1=5
digit_2=4
digit_3=3
digit_4=2
digit_5=1

Thanks!
 
For positive integer values in ST:

Code:
digit_1 := intval MOD 10;
intval := (intval - digit_1) / 10;
digit_2 := intval MOD 10;
intval := (intval - digit_2) / 10;
digit_3 := intval MOD 10;
intval := (intval - digit_3) / 10;
digit_4 := intval MOD 10;
intval := (intval - digit_4) / 10;
digit_5 := intval MOD 10;
 

Similar Topics

Hello, I am using a Hitachi Micro EHV+ for a small project, and I wanted to have a Web visu, done with Codesys V3.5 SP13 Patch 2. I test the...
Replies
6
Views
292
Hello, I have a requirement to manage the text alignment dynamically. So, for example: 1. English Texts should be displayed from Left in...
Replies
0
Views
90
Hello, I am new to Codesys, and am trying to learn about it for a project we're developing. I've got a couple questions, but first a little...
Replies
1
Views
140
Hi everyone, as this is my first experience with Rockwell Software i would like to know what's the best way to make Enumerations?
Replies
10
Views
502
I am trying to get Codesys to work with a couple of Moxa ioLogik E1200 series DIO devices (E1210 and E1211). I am able to write to the E1211 DOs...
Replies
2
Views
168
Back
Top Bottom