powershell - Setting multiple global variables within functions -


i have multiple global variables in script use within function.

$global:row_array = @(); $global:column_array = @(); $global:sorted_array = @(); $global:totalrows = 0; $global:array=@(); $global:m_file;  # button click event handler... $run_it.add_click({     for($i=0; $i -lt 6; $i++){         $global:row_array += $i     }     ...     ...  }) 

now need put $global: qualifier in front of every global variable inside event handler?

or can this:

$run_it.add_click({     for($i=0; $i -lt 6; $i++){         row_array += $i     }     ...     ...     # @ end...     $global:row_array = $row_array;     $global:column_array = $column_array;     $global:sorted_array = $sorted_array;     ... }) 

i can global replace in editor of variables , put $global: in front wanted know if there more elegant way. ref keyword problematic? also, whether functions using global variables idea or not separate discussion… using temporary project.


Comments

Popular posts from this blog

sql - Time in datatime field -

javascript - How to split the success output from an Ajax post? -

java - sharing object across different classes -