Help with reading single digits from a number

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
beneee
Posts: 37
Joined: Tue May 14, 2013 8:18 pm
Has thanked: 6 times
Been thanked: 1 time
Contact:

Help with reading single digits from a number

Post by beneee »

Hi All,

Is there any way of reading the individual digits from a number into separate variables, for instance if the variable ‘Number = 54321’ could I copy it to 5 variables called digit1, digit2, digit3 etc with each one containing a single digit.
So I would have
digit1 = 5
digit2 = 4 etc

I have tried using strings, my mess of a calculation is below but I just end up with an empty string.
____

SplitNumber = left$ (Number,1)
Digit1 = StringToInt$ (SplitNumber)
____


Please help

Thanks
Ben

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Help with reading single digits from a number

Post by medelec35 »

Hi Ben,
You can easily achieve that with the MOD function:
Split Varaible.png
(15.09 KiB) Downloaded 1649 times
Let me know I you would prefer to use a string rather than Int or UIint and I can help you further.

Martin
Martin

beneee
Posts: 37
Joined: Tue May 14, 2013 8:18 pm
Has thanked: 6 times
Been thanked: 1 time
Contact:

Re: Help with reading single digits from a number

Post by beneee »

That does exactly what I wanted, thank you so much.

Ben

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Help with reading single digits from a number

Post by medelec35 »

Your welcome,
Glad its what your after.
Thanks for letting us know
Martin

Post Reply