Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
VikR0001
Level 7

label = Substitute(...) Error?

Why is this line showing a flag in the IDE for wrong syntax?


label = Substitute("Watch Now {1}", "$1.99")
0 Kudos
4 Replies
destruk
Level 10

Re: label = Substitute(...) Error?

Indexes begin at 0.  So try 
label = Substitute("Watch Now {0}", "$1.99")
0 Kudos
destruk
Level 10

Re: label = Substitute(...) Error?

https://sdkdocs.roku.com/display/sdkdoc/Global+String+Functions#GlobalStringFunctions-Substitute(strasString,arg0asString,arg1=%22%22asString,arg2=%22%22asString,arg3=%22%22asString)asString

Substitute(str as String, arg0 as String, arg1 = "" as String, arg2 = "" as String, arg3 = "" as String) as String
Replaces all instances of {0} or ^0 in str with arg0.  Similarly, replaces all instances of {1} or ^1 with arg1, {2} or ^2 with arg2, and {3} or ^3 with arg3.

Example

thing = "book"
color = "red"
print Substitute("My {0} is {1}.", thing, color) ' prints "My book is red."
0 Kudos
VikR0001
Level 7

Re: label = Substitute(...) Error?

I tried:


label = Substitute("Watch Now {0}", "$1,99")


...but Eclipse still is flagging a syntax error. 

BUT the code side-loads and runs fine on Roku!

Could this be a bug in the Eclipse plugin for Roku?
0 Kudos
destruk
Level 10

Re: label = Substitute(...) Error?

If the code works sideloaded in Roku without any errors then yes, I think eclipse isn't updated to return the correct status.
0 Kudos