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: 
squirreltown
Roku Guru

String Ops

I have searched and am unable to find something like this.
Is it possible to look for a certain string within a string?
Sort of like:

string = "123xyz567"
if string contains "xyz"
do something
end if

Thanks
Kinetics Screensavers
0 Kudos
5 REPLIES 5
TheEndless
Channel Surfer

Re: String Ops

You're looking for InStr: http://sdkdocs.roku.com/display/sdkdoc/ ... gAsInteger
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
squirreltown
Roku Guru

Re: String Ops

Thank you theEndless, i looked at that and don't see any "compare" or "contains' type items there. None of the things there are defined, so i could be missing it or just be dense. Which one will do this?

edit ok i see your whole URL now, but i dont see how the As Integer part works

Thanks
Kinetics Screensavers
0 Kudos
squirreltown
Roku Guru

Re: String Ops

if str.Instr("xyz") As integer ) As integer

I'm not seeing how this could be true or false which is what i need.

if str.Instr("xyz") ) = true
Kinetics Screensavers
0 Kudos
RokuMarkn
Visitor

Re: String Ops


8.5 Instr(start As Integer, text As String, substring As String) As Integer

Returns the position of the first instances of substring within text, starting at the specified start position. Returns 0 if the substring is not found. The first position is 1.

So anything greater than zero means the string was found:

if Instr(str, "xyz") > 0 then
Found()
else
NotFound()
end if


The stringops version works the same except indexes are zero-based so -1 is the "not found" case:

if str.Instr("xyz") >= 0 then
Found()
else
NotFound()
end if



--Mark
0 Kudos
squirreltown
Roku Guru

Re: String Ops

Thank you Mark, I got it now. All this stuff seems impossible when you don't know, and easy when you do.

thanks again.
Kinetics Screensavers
0 Kudos