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: 
buenafe
Visitor

Help on - Len (s As String)

How do I get the length of a variable defined as a roString?

r = CreateObject("roRegex", "REGEX PATTERN","")  
'where REGEX PATTERN is complicated regex pattern
first_match = r.Match(v_string).[0]
'v_string is a long html string
print type(first_match)
'returns roString. I expected this to be a "string" .
print len(first_match)
' crashes


I'm posting this at work (no Roku with me 😞 ) so I don't have the exact code with me and error message with me.

I tried the this older post http://forums.roku.com/viewtopic.php?p=244210to convert object to string, but it did not work.
----------------------------------------------------------------------------------
current: two roku XDS 2xs, dtvpal, boxeebox, kylo.tv,
radar: wdlxtv.com
0 Kudos
3 REPLIES 3
belltown
Roku Guru

Re: Help on - Len (s As String)


print len(first_match).ToStr ()
0 Kudos
RokuMarkn
Visitor

Re: Help on - Len (s As String)

The crash is a bug that affects certain string operations when performed on objects that implement ifString but are not Strings (like roString). There is a fix in the pipeline, but until then you can convert your roString to a String with GetString:

first_match_str = first_match.GetString()
print type(first_match_str) ' prints "String"
print Len(first_match_str) ' won't crash


--Mark
0 Kudos
buenafe
Visitor

Re: Help on - Len (s As String)

First, thank you for the help.

I tried both suggestion and still got the crash.

I went with a work around to avoid the "roArray Match(String str)"

using "roList Split(String str)"

and then I took the first element (which is a type String) and applied further string manipulations
to get what I need.

Later, I'll post details of the error for future reference.
----------------------------------------------------------------------------------
current: two roku XDS 2xs, dtvpal, boxeebox, kylo.tv,
radar: wdlxtv.com
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.