I have to convert an integer to a string. The integer has a value from 1 to 12.
The string needs always 2 numbers
result_string = ToString$ (1) // the result_string is "1" but I need "01"
string always 2 numbers 01 02
-
- Valued Contributor
- Posts: 654
- Joined: Fri Aug 19, 2016 2:09 pm
- Location: switzerland
- Has thanked: 182 times
- Been thanked: 179 times
- Contact:
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: string always 2 numbers 01 02
Hello,
You can simply check the length of the string and then add the leading 0 if required.
Calculation: length = Length$(result_string)
Decision: length < 2
Yes: result_string = "0" + result_string
You can simply check the length of the string and then add the leading 0 if required.
Calculation: length = Length$(result_string)
Decision: length < 2
Yes: result_string = "0" + result_string
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel