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: 
Grumpee1
Reel Rookie

Need Help screen getting Invalid value for left-side of expression error

Jump to solution

Running the debugger on Visual Studio Code on a Roku channel I am creating and I am getting an Invalid value for left-side of expression error pointing at: screen = CreateObject("roSGScreen")

Here is the debugger output and main.brs code. Very new to this and would appreciate some help.

Output:

04-13 22:15:03.483 [scrpt.ctx.run.enter] UI: Entering 'NationExtremeWrestling', id 'dev'
------ Running dev 'NationExtremeWrestling' main ------
BrightScript Micro Debugger.
Enter any BrightScript statement, debug commands, or HELP.
Current Function:
001:  sub Main()
002:    m.top.global = {
003:      api_key: "AIzaSyCn9WZzbJdT7XsQOuLYv-kQNmCFbUQ2jQI",
004:*     youTubeApiBaseUrl: "https://www.googleapis.com/youtube/v3/"
005:    }
006:  
007:      screen = CreateObject("roSGScreen")
008:      m.port = CreateObject("roMessagePort")
Source Digest(s):
pkg: dev 0.0.0 b434e374 NationExtremeWrestling
Invalid value for left-side of expression. (runtime error &he4) in pkg:/source/main.brs(4)
Backtrace:
#0  Function main() As Void
   file/line: pkg:/source/main.brs(7)
Local Variables:
global           Interface:ifGlobal
m                roAssociativeArray refcnt=2 count:0
screen           <uninitialized>
scene            <uninitialized>
msg              <uninitialized>
 
Main.brs:
 
sub Main()
  m.top.global = {
    api_key: "AIzaSyCn9WZzbJdT7XsQOuLYv-kQNmCFbUQ2jQI",
    youTubeApiBaseUrl: "https://www.googleapis.com/youtube/v3/"
  }

    screen = CreateObject("roSGScreen")
    m.port = CreateObject("roMessagePort")
    screen.setMessagePort(m.port)
 
    scene = screen.CreateScene("VideoScene")
    screen.show()
 
    while true
      msg = wait(0, m.port)
      if type(msg) = "roSGScreenEvent"
        if msg.isScreenClosed() then exit while
      end if
    end while
  end sub
0 Kudos
1 Solution

Accepted Solutions
TwitchBronBron
Streaming Star

Re: Need Help screen getting Invalid value for left-side of expression error

Jump to solution

The error message is actually complaining about line 4:

Invalid value for left-side of expression. (runtime error &he4) in pkg:/source/main.brs(4)

I don't think you are allowed to completely reassign m.top.global. so try doing m.top.global.api_key = "AIzaSyCn9WZzbJdT7XsQOuLYv-kQNmCFbUQ2jQI"

m.top.global.youTubeApiBaseUrl = "https://www.googleapis.com/youtube/v3"

 

Also, m.top.global.might not be assigned at that phase.of the app. So it might still fail. 

View solution in original post

0 Kudos
3 REPLIES 3
TwitchBronBron
Streaming Star

Re: Need Help screen getting Invalid value for left-side of expression error

Jump to solution

The error message is actually complaining about line 4:

Invalid value for left-side of expression. (runtime error &he4) in pkg:/source/main.brs(4)

I don't think you are allowed to completely reassign m.top.global. so try doing m.top.global.api_key = "AIzaSyCn9WZzbJdT7XsQOuLYv-kQNmCFbUQ2jQI"

m.top.global.youTubeApiBaseUrl = "https://www.googleapis.com/youtube/v3"

 

Also, m.top.global.might not be assigned at that phase.of the app. So it might still fail. 

0 Kudos
Grumpee1
Reel Rookie

Re: Need Help screen getting Invalid value for left-side of expression error

Jump to solution

Thanks so much, fixed the error and you were right, it doesn't seem like it has been assigned so there was a failure. Will work on it some more. Thanks again!

0 Kudos
TwitchBronBron
Streaming Star

Re: Need Help screen getting Invalid value for left-side of expression error

Jump to solution

m.global isn't available in the main thread by default. We usually do something like this in our apps

sub main()
    ...stuff
    screen = createObject("roSGScreen")
    m.global = screen.getGlobalNode()
    ...more stuff
end sub

 

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.