Millisecond Forums

Display score integer as text?

By Chemical_Music - 1/5/2015

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)

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

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

/score = 5

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

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%>")
By Chemical_Music - 1/5/2015

Thank you so much!