Questions tagged [brightscript]

Brightscript is a BASIC-like language developed for the Roku and Brightsign hardware platforms.

Brightscript is a BASIC-like language developed for the Roku and Brightsign hardware platforms.

Brightscript is single threaded, procedural language with some object oriented features. It lacks support for Classes and Inheritance. Brightscript allows only one global variable, "m". However m can contain a complex global data structure. Arrays are one-dimensional; however, you can create arrays of arrays.

There are two primary types of array variables: roArray and roAssociativeArray.

Arrays can be defined with a CreateObject statement or using shorthand

varname=createobject(roArray,5,true) 

creates an expandable array containing 5 elements. Alternatively:

varname=[]

creates an empty, but expandable Array.

roAssociativeArrays can also be described as a data dictionary. They can be created as follows:

varname=createobject(roAssociativeArray)

or

varname={}

using curly brackets.

To assign values to an Array:

varname=[100,200,"ABCD","ZYXW"]

or

varname[0]=100
varname[1]=200
varname[2]="ABCD"
varname[3]="ZYXW"

to assign values to an AssociativeArray or "AA":

varname={name:"John Smith",address:"1023 West Alameda",telephone:"415-555-1212"}

or

varname={}
varname["name"]="John Smith"
varname["address"]="1023 West Alameda"
varname["telephone"]="415-555-1212"

a mode which allows almost any ASCII character to be used as a key, or, using dot notation:

varname={}
varname.name="John Smith"
varname.address="1023 West Alameda"
varname.telephone="415-637-1283"

Aside from the usual text and numeric manipulation functions, Brightscript also has specialized objects that can be created, such as "roAudioPlayer", "roVideoPlayer" and many different display screen types, the most commonly used are "roPosterScreen" and "roGridScreen". These objects are created and assigned a reference variable in the following manner:

screen=CreateObject("roPosterScreen")

It could then be populated:

item1={ShortDescriptionLine1:"item 1"}
item2={ShortDescriptionLine1:"item 2"}
item3={ShortDescriptionLine1:"item 3"}

content=[item1,item2,item3]   

screen.setcontentlist(content)

Note that item 1 2 and three are roAssociativeArrays and that content is an roArray containing three roAssociativeArrays.

To display the screen:

screen.show()

Instead of a REM statement, Brightscript uses the single quote:

'this is a comment

Program Execution statements include:

  • For / End For / Exit for
  • While / End While / Exit While
  • If / Then / Else / Else If / End If

Brightscript is not Case Sensitive for the most part; however, string comparisons and AssociativeArray keys can be case sensitive.

For more information on Brightscript, please see the following links:

Roku Developer Guide

BrightScript Language Reference

Roku Developer Program signup link

And the frequently helpful Roku Developers Forum

415 questions
2
votes
0 answers

Why same fonts are showing different look on different roku devices?

I am working on bright script using scene graph. I have used fonts(Lato-Light, Lato-Regular and Lato-Bold) but these font shows different look (UI) in multiple roku devices. I have tested it in different roku devices(Roku-2, Roku-3, Roku-4 and…
Vijay Kumar
  • 141
  • 1
  • 13
2
votes
2 answers

In-Channel Monthly / Annual Subscription issue in Roku / Bright Script

I have gone through all of the documentation stuff and have read about the roChannelStore component that can be used for in-channel purchases or subscriptions. I have also found out about the "Fake Server" approach for local development…
Basit Nizami
  • 345
  • 4
  • 14
2
votes
2 answers

How to develop a custom keyboard in Brightscript?

I'm trying to create a custom keyboard in Brightscript. I found Youtube and Netflix are using their own keyboard layout.And the Roku's keyboard is kinda different. Not clean like Youtube and Netflix. From Roku's Brightscript documentation, I found…
Renjith V R
  • 2,981
  • 2
  • 22
  • 32
2
votes
2 answers

Roku: Reading a text file present in server

I want to read a text file present in a server from my Roku program. I reffered the following question. Read and write from temp file in Roku The above link has solution to read file from tmp/. So, I tried something like…
MayurK
  • 1,925
  • 14
  • 27
2
votes
2 answers

Roku - Brightscript on eclipse is not working

Now I'm learning Roku's BrightScript. I found eclipse is a good IDE for BrightScript development. But I'm not sure, should I register in their Roku's developer website? I have a sample code. When I used to run the code , it is showing this I just…
Renjith V R
  • 2,981
  • 2
  • 22
  • 32
2
votes
2 answers

How to compile C++ code for Roku?

I have an android streaming client application which uses Java and cpp code. I want to port my application to Roku. I understand that Roku recommends only BrightScript for apps development. 1) According to this link (C/C++ development in Roku),…
MayurK
  • 1,925
  • 14
  • 27
2
votes
1 answer

ParseJson Error Roku

I am parsing JSON data. I am using Roku OS 7.0 my code : if (code = 200) json = ParseJSON(msg.GetString()) But it throws "ParseJson:Unknown Identifier Error". How can I solve this?
Saty
  • 2,563
  • 3
  • 37
  • 88
2
votes
1 answer

How to get Roku's device geolocation?

I need to deliver content with geolocation restrictions, so I need to know exactly what's the physical location of device. Accordingly to Documentation there is two methods GetCurrentLocale() and GetCountryCode(), however documentation relays on…
Roberto14
  • 689
  • 6
  • 20
2
votes
1 answer

C or C++ development in Roku

Is it possible to develop applications for Roku in C or C++ as the SDK is written in C? If yes, how? If no, then which languages other than Brightscript can apps be developed in?
khateeb
  • 5,265
  • 15
  • 58
  • 114
2
votes
1 answer

Is there a programmatic way to prevent Roku to go to screen saver mode?

I am working on an application that waits for some time (several hours) and then play some videos and then wait again and then play videos again and so on. Whether it is time to play content or it is time to wait is decided by the web service that…
Muhammad Tahir
  • 5,006
  • 1
  • 19
  • 36
2
votes
3 answers

Remove white spaces from BrightScript string

I am attempting to remove leading and trailing white spaces from my string using regex regexQuote = CreateObject("roRegex", "/^[ ]+|[ ]+$/g+", "i") regexQuote.ReplaceAll(noSpaceString) print noSpaceString [EDIT] regexQuote = CreateObject("roRegex",…
dan_vitch
  • 4,477
  • 12
  • 46
  • 69
2
votes
2 answers

How do I open another channel from one channel in Roku?

I am able to use curl to get apps and the apps id from my computer in Roku device. And ultimately, I am able to launch channels using curl from my local computer with e.g. curl -d '' 'http://192.x.x.x:8060/launch/33739' but what I am looking for…
2
votes
1 answer

BrightScript Eclipse Plugin Not Showing Up After Install on OSX

After installing the BrightScript Eclipse Plugin for Roku development it acted like it installed fine but is not visible anywhere in Eclipse. What am I doing wrong?
Brian F Leighty
  • 922
  • 11
  • 22
2
votes
1 answer

Parsing JSON with Brightscript

I'm trying to parse JSON, based on the example here: http://blog.roku.com/developer/2012/07/16/json-support-comes-to-roku/ jsonAsString = ReadAsciiFile("pkg:/json/sample1.json") m.json = ParseJSON(jsonAsString) ShowPosterScreen(m.json.Videos,…
taraloca
  • 9,077
  • 9
  • 44
  • 77
2
votes
1 answer

Starting with Roku app development

I want to start learning Roku, can any one suggest me some sites and videos, doc, etc to start up. please provide me some links
Pradeep Kumar
  • 401
  • 5
  • 18