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

Re: App freezes when network unplugged

Instead of, but similar to, the printon setting, I use this and it works ok for me...

In my startup code...
m.Timer=CreateObject("roTimeSpan")
m.Timer.Mark()
m.Development = CreateObject("roAppInfo").IsDev()


And a routine in my global routines
Sub Trace(Value as string)
if m.Development=true print (stri(m.Timer.TotalMilliseconds())+": "+Value)
End Sub


Then I can call it anytime and it prints if in dev, the drawback is if I do a complex function to generate the value, it still runs in production, but the one area I do that I surrounded with the same m.Development check.
0 Kudos
EnTerr
Roku Guru

Re: App freezes when network unplugged

"sjb64" wrote:
Instead of, but similar to, the printon setting, I use this and it works ok for me...

Well done, good sir!
I think i'll ugh, borrow that for my code. There is actually already a timer somewhere - a bit obscure but i found it - in ifAppManager.

'main() init section. keep singletons handy
m.roAppManager = createObject("roAppManager")
m.roAppInfo = createObject("roAppInfo")
m.isSideLoaded = roAppInfo.isDev()
...

function trace(this, that = ""):
if m.isSideLoaded then
print m.roAppManager.getUptime(); ": "; this; that
end if
end function

An advantage of using semicolon separator instead of string concat is that `this` can now be any type (e.g. array, dictionary) and let print handle the printing
0 Kudos