How can I test the length of all the characters in a list and adjust the location of Output( based on the length?
Strings are your friend!
I spoke with a friend on this and she gave me the idea to store the list elements into a string and then output the string instead of the list. The trick was figuring out how to store the numbers in a string. I found the toString(
function which helped with that.
Here's the working code snippet.
toString(∟STATS(1))→Str0
For(I,2,6,1
Str0+" "+toString(∟STATS(I))→Str0
End
That gave me the string of numbers and spaces formatted nicely. My last issue was how to center it where again my friend came to my rescue and suggested getting the length of the string /2 as the column coordinate. I tried using that and was a bit off center so I subtracted 2 to get a column. The way I did this is in the code below.
ClrHome
While not(getKey
Output(5,(int(length(Str0)/2-2)),Str0
End
So the full working code is
0→dim(∟STATS
For(I,1,6,1
0→dim(∟ROLLS
randInt(1,6,4)→∟ROLLS
1+sum(not(cumSum(∟ROLLS=min(∟ROLLS))))→X
∟ROLLS(X)-min(∟ROLLS)→∟ROLLS(X)
sum(∟ROLLS)→∟STATS(1+dim(∟STATS
End
toString(∟STATS(1))→Str0
For(I,2,6,1
Str0+" "+toString(∟STATS(I))→Str0
End
ClrHome
While not(getKey
Output(5,(int(length(Str0)/2-2)),Str0
End
ClrHome
SetUpEditor