Your Digital Media Has Never Looked So Good

Topic Author
Posts: 12
Joined: Wed Mar 17, 2010 6:15 am

Global Variables concept

Thu May 27, 2010 5:15 am

Hi is there a way store the variables globally.
I mean to say If i declare a variable I want access it in all functions.
Presently to access the values in different functions Iam writting below code.Plz suggest is this Correct method
function one()

function two()
print m.variable 'output is 1

is this way correct.Plz suggest me.....
Naveed Anjum
Posts: 11
Joined: Wed May 05, 2010 4:48 am

Re: Global Variables concept

Thu May 27, 2010 5:25 am

If you want to use a variable that is accessed throughout your file say "Test.brs", then the code that you mention above is true. I dont know about the application wise global variables..
User avatar
Roku Engineering
Posts: 796
Joined: Tue Sep 22, 2009 2:29 pm

Re: Global Variables concept

Thu May 27, 2010 10:10 am

There are no global variables, but there is a "global m scope".... Meaning that the scope of m that is not in an object scope is shared by all static functions that are not part of an object. This is the scope of the Main() function.


Function Main()
m.variable = 100
End Function

Function One()
m.variable = 1
End Function

Function Two()
print m.variable 'output is 1
End Function

If this is not working for you, check that One() and Two() are not methods of different objects....

Who is online

Users browsing this forum: No registered users and 5 guests