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 to all, can you please provide an example of obtaining a current working directory as a string in CodeSys? For example, during starting the...
Replies
7
Views
217
Hello to all, I'm just starting with using CodeSys. Immediately, I have noticed that Codesys doesn't use data blocks like for example S7 does...
Replies
11
Views
221
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
7
Views
442
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
133
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
223
Back
Top Bottom