Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Gav (HeyBud) on June 11, 2014, 06:51:39 AM

Title: Help with breaking up a 3 digit int into 3 separate integers [SOLVED]
Post by: Gav (HeyBud) on June 11, 2014, 06:51:39 AM
Hello,
I need help with breaking up a 3 digit int into 3 separate integers.
For example: myInt = 150
For my purpose, I need to get an int for each place value. So from 150 i'd like to get ints for 1 and 5 and 0.

Would this be possible at all with playmaker?
 :-\
Thanks
Title: Re: Help with breaking up a 3 digit int into 3 separate intagers
Post by: jeanfabre on June 11, 2014, 07:53:03 AM
Hi,

 yes totally, the easiest way, is to convert your int into a string, then take each character, and back into an int.

use "get substring" to get to a particular character, and use "iterate" ( use the ecosystem (https://hutonggames.fogbugz.com/default.asp?W1181) to get this action) to go through each chars in turn to process them.

 you may want also to use ArrayMaker (https://hutonggames.fogbugz.com/default.asp?W715) to store your results, especially if you don't know the number of digits ( meaning you can't hardcode three values for example).

Bye,

 Jean
Title: Re: Help with breaking up a 3 digit int into 3 separate integers
Post by: Gav (HeyBud) on June 15, 2014, 09:40:40 AM
Jean,
I just wanted to let you know this solution worked for me.
Thank you!
Title: Re: Help with breaking up a 3 digit int into 3 separate integers [SOLVED]
Post by: jeanfabre on June 16, 2014, 03:38:17 AM
Hi,

 Thanks.

Bye,

 Jean