Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
jackhand
Visitor

StrI() Function create whitespace

I noticed the StrI() Function create whitespace in front of the string. For example the following operation StrI(3) produces the following string " 3" instead of "3".

The following is how I am currently eliminating the leading whitespace; however, is there a better way?

sString = StrI(n)
nWhitespace = Instr(1, sString , " ")
if nWhitespace = 1 then
   sString = Mid(sString , 2)
end if

0 Kudos
1 REPLY 1
tim_beynart
Channel Surfer

Re: StrI() Function create whitespace

The space is there for the negative sign. Use toStr() on the number instead. https://sdkdocs.roku.com/display/sdkdoc/ifToStr

myInteger = 12345
myIntegerString = myInteger.ToStr()
0 Kudos