can xml reference functions outside of xml?

I have a function I use to record time that I want to reference in an xml document I’m using to create a countdown timer. Is the code within the xml document capable of recognizing that I am referencing a function within my primary brightscript documents, or do I have to do something special to point that fact out?

to clarify, I have this in the xml document

      sub changeTime(seconds as integer)
        m.label.text = CountdownTime(seconds)
        return
      end sub

And I have this in a brs document

function CountdownTime(seconds as integer) as string
    h = seconds / 3600
    m = (seconds - h * 3600) / 60
    s = seconds Mod 60
    Return h.ToStr() + ":" + Right("0" + m.ToStr(), 2) + ":" + Right("0" + s.ToStr(), 2)
end function

I can’t help you with the scene graph stuff, but I can tell you that the time formatting code of mine that you copied and changed has two fundamental flaws: you’re using dynamic types instead of declared types, so you’ll end up with floating values instead of integer values when you divide; and you’re using “m”, the global BrightScript “this” pointer, as your minutes variable, which will play havoc with anything else in your code that references “m”.

Here’s the original code:

' Format the time left: "h:mm:ss"
Function formatTimeLeft (seconds As Integer) As String
    h% = seconds / 3600
    m% = (seconds - h% * 3600) / 60
    s% = seconds Mod 60
    Return h%.ToStr () + ":" + Right ("0" + m%.ToStr (), 2) + ":" + Right ("0" + s%.ToStr (), 2)
End Function

“belltown” wrote:
I can’t help you with the scene graph stuff, but I can tell you that the time formatting code of mine that you copied and changed has two fundamental flaws: you’re using dynamic types instead of declared types, so you’ll end up with floating values instead of integer values when you divide; and you’re using “m”, the global BrightScript “this” pointer, as your minutes variable, which will play havoc with anything else in your code that references “m”.
Oh! Well… hmm… it’s a good thing I hadn’t referenced that code in my current implementation! Haha. I rewrote it assuming that the % objects didn’t actually matter and were just some writing convention you were using. Thank you for correcting me on that front.

Eh, you can always fix() it. And let me use an obscure function for no raisin:

' Format the time left: "h:mm:ss"'
function formatTimeLeft(secs as Integer):
    hrs = seconds\3600           ''or fix(seconds/3600)
    mins = seconds\60 - 60*hrs   ''or fix(seconds/60) - 60*hrs
    return substitute("^0:^1:^2", hrs.toStr(), right("0"+mins.toStr(), 2), right("0"+(secs mod 60).toStr(), 2)
end function

The main question however remains…

PS. updated to use int division as reminded by RokuKC

“EnTerr” wrote:
Eh, you can always fix() it. And let me use an obscure function for no raisin:

' Format the time left: "h:mm:ss"
function formatTimeLeft(secs as Integer):
    hrs = fix(seconds/3600)
    mins = fix(seconds/60) - 60*hrs
    return substitute("^0:^1:^2", hrs.toStr(), right("0"+mins.toStr(), 2), right("0"+(secs mod 60).toStr(), 2)
end function

The main question however remains…
I just continue to rack up the questions, myself. Like now I can’t seem to call the screen up at all because I call a function that displays and changes the time, and then it crashes as soon as i try to do a single arithmetic problem. I can’t tell what the problem is with that.

“EnTerr” wrote:
Eh, you can always fix() it. And let me use an obscure function for no raisin:

Maybe it’s less readable to non-BrightScript experts, but I would just use the integer division operator \ instead.

“RokuKC” wrote:

“EnTerr” wrote:
Eh, you can always fix() it. And let me use an obscure function for no raisin:

Maybe it’s less readable to non-BrightScript experts, but I would just use the integer division operator \ instead.
I didn’t even know that existed. Good to know.

“belltown” wrote:

“RokuKC” wrote:

“EnTerr” wrote:
Eh, you can always fix() it. And let me use an obscure function for no raisin:

Maybe it’s less readable to non-BrightScript experts, but I would just use the integer division operator \ instead.
I didn’t even know that existed. Good to know.
I’m glad this dilemma was helpful for you XD

“RokuKC” wrote:
Maybe it’s less readable to non-BrightScript experts, but I would just use the integer division operator \ instead.
I would have, if i could remember it is "". Today I pondered for a moment if int division was added at some point, even tried “div” and “//” but no dice. Somewhat embarrassing really…

“EnTerr” wrote:

“RokuKC” wrote:
Maybe it’s less readable to non-BrightScript experts, but I would just use the integer division operator \ instead.
I would have, if i could remember it is "". Today I pondered for a moment if int division was added at some point, even tried “div” and “//” but no dice. Somewhat embarrassing really…
If it makes you feel any better, I don’t think it was added until 7.0. And I’m sure you’ll find some joy in the fact that the Eclipse plugin still doesn’t recognize it as valid syntax…

“TheEndless” wrote:

“EnTerr” wrote:
I would have, if i could remember it is "". Today I pondered for a moment if int division was added at some point, even tried “div” and “//” but no dice. Somewhat embarrassing really…
If it makes you feel any better, I don’t think it was added until 7.0.
1.5 years ago actually, together with << and >>. Hindsight 20/20

And I’m sure you’ll find some joy in the fact that the Eclipse plugin still doesn’t recognize it as valid syntax…
Umm… who? [spoiler=star-lord:ydpytikf][youtube:ydpytikf]vWh6VllqX_4[/youtube:ydpytikf][/spoiler:ydpytikf]
Speaking of which, didn’t RokuCo hire someone to write a proper IDE last year? I seem to recollect there was job posting on that which is gone now. So by deduction, one would expect that turd be gone soon?

Wow, I really need to read those release notes more often. There’s all kinds of goodness that’s been added since the last time I looked. :grinning_face_with_smiling_eyes:

-JT

“EnTerr” wrote:

“TheEndless” wrote:

“EnTerr” wrote:
I would have, if i could remember it is "". Today I pondered for a moment if int division was added at some point, even tried “div” and “//” but no dice. Somewhat embarrassing really…
If it makes you feel any better, I don’t think it was added until 7.0.
1.5 years ago actually, together with << and >>. Hindsight 20/20

And I’m sure you’ll find some joy in the fact that the Eclipse plugin still doesn’t recognize it as valid syntax…
Umm… who? [spoiler=star-lord:3blt4gik][youtube:3blt4gik]vWh6VllqX_4[/youtube:3blt4gik][/spoiler:3blt4gik]
Speaking of which, didn’t RokuCo hire someone to write a proper IDE last year? I seem to recollect there was job posting on that which is gone now. So by deduction, one would expect that turd be gone soon?

As much as I’m sure you’re enjoying discussing this, can we please return to the topic at hand? I really would like to figure this stuff out so I can finish up this program. My inexperience with screen graph applications is extreme and cannot find the information I need to solve these problems I’m having from anywhere.

“scaper12123” wrote:
As much as I’m sure you’re enjoying discussing this, can we please return to the topic at hand? I really would like to figure this stuff out so I can finish up this program. My inexperience with screen graph applications is extreme and cannot find the information I need to solve these problems I’m having from anywhere.
My apologies for the diversion. As i said
The main question however remains…
I’ll leave to the Roku* evangelists on staff to answer it - they are being paid to be enthusiastic about and to shill for the SG xml-ography. The question is broad, so even the more reason it falls under their auspices.

“scaper12123” wrote:
I have a function I use to record time that I want to reference in an xml document I’m using to create a countdown timer. Is the code within the xml document capable of recognizing that I am referencing a function within my primary brightscript documents, or do I have to do something special to point that fact out?

If I understand what you are asking, you need to reference the code with a script tag:

<?xml version="1.0" encoding="utf-8" ?>
<component name="basic" extends="Scene" initialFocus="Channels">
<script type="text/brightscript" uri="pkg:/components/radio.brs" />
<script type="text/brightscript" uri="pkg:/source/utils.brs" />

Hope that helps answer your question, if not, post back here.

“EnTerr” wrote:

I’ll leave to the Roku* evangelists on staff to answer it - they are being paid to be enthusiastic about and to shill for the SG xml-ography. The question is broad, so even the more reason it falls under their auspices.

I think most Roku employees are enthusiastic because we believe in the product, the company and the potential for revolutionizing the TV space.
I don’t know anyone who isn’t at least a little bit excited, even the people who have been here for many years.

  • Joel

“RokuJoel” wrote:

“EnTerr” wrote:

I’ll leave to the Roku* evangelists on staff to answer it - they are being paid to be enthusiastic about and to shill for the SG xml-ography. The question is broad, so even the more reason it falls under their auspices.
I think most Roku employees are enthusiastic because we believe in the product, the company and the potential for revolutionizing the TV space.
I don’t know anyone who isn’t at least a little bit excited, even the people who have been here for many years.
RokuJoel,
perhaps you misread what i said. I was not talking about Roku devices or employees.

Rather, it was about the “SDK2.0” - hinting that the way scene graph is implemented is far from “great”. It’s distant from “good” even - on which i opine as someone who has used scene graph elsewhere. So, what i mean was that the paid evangelists are bound by duty to be enthusiastic about rSG - whether they like it (because have not seen better and think it’s “the paradigm shift” that makes rSG so hard to use) or not - they ought to follow the party line and promote/explain it. It’s like having Trump as GOP nominee - like it or not, have to drum up that “the Donald” is great. OTOH i as “independent voter” have the luxury of choosing what questions to answer.

I am curious if someone with experience using scene graphs on other platforms can share opinion on rSG ?
Contrast & compare would be great!

“RokuJoel” wrote:
If I understand what you are asking, you need to reference the code with a script tag:



OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOH! Ok, that makes sense. Thank you.