How can we do put a number to 3number
-
@Richard Great minds think alike!
-
@pianofire if only I could type faster.
-
Thank you so much,
I'm still not comfortable with the functions, I will try to understand them and I will put them in my program -
I understand your functiont, they are the same
-
For my project digits or padlen must be equal to 3
-
So you could just have a function:
function zeroPadInt(integer) result = str(integer) while len(result) < 3 loop result = "0" + result repeat return result
But in another project you may need a different length so the first version has more reuse value
-
One thing that Petit Computer did was allow multiplying of strings. For instance...
myvar = "01" * 4
This would result in "01010101". Would be nice if that sort of feature were added.
-
Though Petit Computer may provide this feature, I don't believe I've seen this feature in any other languages. It's really just as easy for you to write a simple function that does the same thing.
function appendCopy( str, times) String appendCopy = str for i = 0 to times loop appendCopy = appendCopy + str repeat return appendCopy String newString = appendCopy("01", 4)
BTW, I've not tried appendCopy += str which might also work. But, even if I got something not quite right, you get the idea.
-
TIP: if you put 3 back ticks ``` around a block of code it will format it:
-
@pianofire, Thanks! I also see now that there is a "code" option in the above content choices... dah! : )