Forum Discussion

korsar01's avatar
korsar01
Occasional Contributor
15 years ago

Global variables in C# Scripts

Hello. How can I use global variabels in C# Scripts?



For example:

function Main()


{


try


{


 


Init()


Test1()// Enter your code here.


}


catch(exception)


{


Log["Error"]("Exception", exception["description"]);


}


}



function Init()


Init()

{



//init



var iexplore;


var form;


var textbox;


var cell;


var page;


var table;


var table2;


var submitButton;



}



I want that all varaibals coud be seen in all functions.

  • Hi,


    You can just declare your variables outside the function in this case.


    var a,b,c,d;


    function main()


    {init();test();}


    function init()


    {a=b=c=d=1;}


    function test()


    {Log["Message"](a+" "+b+" "+c+" "+d);}



    If you want to get access to these variables from another script, just add the script with variables declaration to it via //USEUNIT statement.