401
Views
3
Comments
Split a number into digits and iterate through it
Question

Hi.I am new to outsystems. Can someone suggest how to split a number into individual digits and iterate through it ? Like the conventional d=a%10 ,a=a/10, will it work?Or , is there another specific way to do it? 

2022-05-06 16-37-40
Joseph Danne Enriquez

Hi ankit!

You could use the Substr() function to split that number. One way of doing it would be Substr(<string variable>,looping count variable,1) then loop it in a ForEach. Use the Length() of that string to count how many the times that loop would go.

Reference:
https://success.outsystems.com/Documentation/11/Reference/OutSystems_Language/Logic/Built-in_Functions/Text#Substr


Kind regards,
Joseph Enriquez

UserImage.jpg
ankit raj

Joseph Enriquez wrote:

Hi ankit!

You could use the Substr() function to split that number. One way of doing it would be Substr(<string variable>,looping count variable,1) then loop it in a ForEach. Use the Length() of that string to count how many the times that loop would go.

Reference:
https://success.outsystems.com/Documentation/11/Reference/OutSystems_Language/Logic/Built-in_Functions/Text#Substr


Kind regards,
Joseph Enriquez

Thanks.


2018-10-04 11-30-51
glenn michiels

Hi Ankit,

First of all welcome to Outsystems!

In attachment you'll find an example of how to split decimal numbers using Substring().
With some small tweaking you can alter it to return just the numbers and skip the delimiters.

If you got any more questions just let me know.

Kind regards,
Glenn

ExampleSplitNumbers.oml
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.