DLC
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2012
04:41 AM
Re: Help for begginer
Hi again,
I have two other beginner questions please :roll: .
1)When you have two .brs files in the source folder, can you use the objects created in one file in the other?
I have a main.brs, with a Main() function that ends like this :
Then i have a second .brs file, which starts like this :
On the debugger console, I see :
The Second() function is called, so I think that the "return my_array" of the Main() has been done, but it doesn't want to print the array. Is there a special way to take an object from another file, or do I have to create all the functions that will use the array in the same .brs file?
2) Is it possible to return more than one object? For example if I create two arrays in my main(), can i use :
or
?
Thank you
Edit : I tried to copy the function Second() under my function Main() and deleted the second .brs file, but it wasn't called this time, as the debugger console stopped after printing "1 2 3 4 5" this time.
So i set it as it was the first time, with two files, and now the Second() function isn't called anymore :cry:
I have two other beginner questions please :roll: .
1)When you have two .brs files in the source folder, can you use the objects created in one file in the other?
I have a main.brs, with a Main() function that ends like this :
print "my_array"
print my_array
return my_array
Second()
end sub
Then i have a second .brs file, which starts like this :
Sub Second()
print "my_array"
print my_array
On the debugger console, I see :
my_array
1
2
3
4
5
my_array
<UNINITIALIZED>
The Second() function is called, so I think that the "return my_array" of the Main() has been done, but it doesn't want to print the array. Is there a special way to take an object from another file, or do I have to create all the functions that will use the array in the same .brs file?
2) Is it possible to return more than one object? For example if I create two arrays in my main(), can i use :
return my_array
return my_second_array
or
return my_array ; my_second_array(or use a "," instead of the ";")
?
Thank you
Edit : I tried to copy the function Second() under my function Main() and deleted the second .brs file, but it wasn't called this time, as the debugger console stopped after printing "1 2 3 4 5" this time.
So i set it as it was the first time, with two files, and now the Second() function isn't called anymore :cry:
SkipFire
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2012
05:58 AM
Re: Help for begginer
The variable is only available in the scope it was created, so once you left the method it was no longer available. You can pass the variable as a parameter and update it, then the new values will come back, or you can set it up as a function that returns the variable. Another option is to look into the global "m", but in any programming language you should be careful when using global variables.
DLC
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2012
07:51 AM
Re: Help for begginer
"SkipFire" wrote:
you can set it up as a function that returns the variable.
My Main() function already returns the array.
Or i didn't understand what you're telling me?
"SkipFire" wrote:
You can pass the variable as a parameter and update it, then the new values will come back
You mean to change my Main() to Main(roArray my_array) as object?
SkipFire
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2012
08:28 AM
Re: Help for begginer
Specific to your function you will want something like:
Sub Main()
MainArray = Second()
End Sub
Function Second() As roArray
MyArray = new roArray
dostuff
return MyArray
End Function
OR
Sub Main()
MainArray = new roArray()
Second(MainArray)
End Sub
Sub Second(MyArray As roArray)
dostuff
End Sub
Sub Main()
MainArray = Second()
End Sub
Function Second() As roArray
MyArray = new roArray
dostuff
return MyArray
End Function
OR
Sub Main()
MainArray = new roArray()
Second(MainArray)
End Sub
Sub Second(MyArray As roArray)
dostuff
End Sub

RokuJoel
Binge Watcher
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2012
08:31 AM
Re: Help for begginer
If the main function hits a return, it will exit the channel. What you really want is:
you have to explicitly pass the array to the function and explicitly return the array back to the calling function.
It doesn't matter which .brs file a function is in, they are all treated as if they are in the same file. Sub main is the first subroutine that is called when a channel is launched and when sub main() exits, the channel exits.
- Joel
sub main()
my_array=[1]
my_array=second(my_array) 'pass my_array to the second function and get the altered array back.
print my_array
stop
end sub
function second(my_array as object) as object
for i=2 to 5
my_array.push(i)
return my_array
end for
end function
you have to explicitly pass the array to the function and explicitly return the array back to the calling function.
It doesn't matter which .brs file a function is in, they are all treated as if they are in the same file. Sub main is the first subroutine that is called when a channel is launched and when sub main() exits, the channel exits.
- Joel
DLC
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2012
09:24 AM
Re: Help for begginer
Perfect, I also managed to divide the array in three smaller arrays thanks to this method 😄 .
Thank you very much.
Thank you very much.
SkipFire
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2012
09:40 AM
Re: Help for begginer
As an extra note, the channel will also exit once there are no more open screens even if there is code left in the method.
DLC
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2012
10:15 AM
Re: Help for begginer
Hello,
Guess who has another beginner question :roll:
I have created a SpringBoard like this :
My problem is that though I haven't defined the starRating, I still have the stars on the screen. They are all grey, but still here. Is it possible to remove them or to put them white so that they would become invisible?
Thank you.
Guess who has another beginner question :roll:
I have created a SpringBoard like this :
o = CreateObject("roAssociativeArray")
o.Title = title
o.Description = description
o.SDPosterUrl = sdposterurl
o.HDPosterUrl = hdposterurl
o.ReleaseDate = releasedate
My problem is that though I haven't defined the starRating, I still have the stars on the screen. They are all grey, but still here. Is it possible to remove them or to put them white so that they would become invisible?
Thank you.


Roku Employee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2012
10:21 AM
Re: Help for begginer
"DLC" wrote:
My problem is that though I haven't defined the starRating, I still have the stars on the screen. They are all grey, but still here. Is it possible to remove them or to put them white so that they would become invisible?
I think this is what you're looking for: viewtopic.php?f=34&t=47605
SkipFire
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2012
11:20 AM
Re: Help for begginer
"DLC" wrote:
My problem is that though I haven't defined the starRating, I still have the stars on the screen. They are all grey, but still here. Is it possible to remove them or to put them white so that they would become invisible?
Use SetStaticRatingEnabled(false). Many of the other fields will just not show if there is no value in them.