Millisecond Forums

Display score integer as text?

https://forums.millisecond.com/Topic15296.aspx

By Chemical_Music - 1/5/2015

Hi,
I am trying to display a running score as the participant completes a task, and I am having trouble using the format function to add the score to a string that can be used as text.

Here is my code, with values.score as the integer that gets updated in the task: 

<item scoretext>
/1 = format ("Score: %i", values.score)
</item>

<text scoretext>
/items = scoretext
/ position = (80%, 5%)
/ size = (50,50)
</text>

When I display scoretext, all it does is show the string "Score: %i" rather than replacing %i with the integer.
Am I supposed to use the format function in a different way?

By Dave - 1/5/2015

The proper way to use a function inline is

<values>
/score = 5
</values>

<text mytext>
/ items = ("<%format(~"Score: %i~", values.score)%>")
</text>

If values.score is an integer anyway, you do not need the format function at all, btw. You simply do:

<text mytext>
/ items = ("Score: <%values.score%>")
</text>
By Chemical_Music - 1/5/2015

Thank you so much!