I've a general question about the best practice in programming with function in AutoIT or in general:
supposing to have multiple unrelated variables that you set only inside a function and read outside (after) that function, how would you do?
would you declare them as global at the very beginning of the script? or return the variables from the function as an array (losing the useful variable names)? what's the best/most used practice?
I read that global variables should be avoided... but I can't find a better alternative...
Example of how I'ld do such a script, with global variables:
How would you do it instead?
supposing to have multiple unrelated variables that you set only inside a function and read outside (after) that function, how would you do?
would you declare them as global at the very beginning of the script? or return the variables from the function as an array (losing the useful variable names)? what's the best/most used practice?
I read that global variables should be avoided... but I can't find a better alternative...
Example of how I'ld do such a script, with global variables:
[ autoit ]
Global $current_song_names, $last_query_PCname, $last_query_time some code aaaaaa... query() some code bbbbbb... query() some code cccccc... query() some code dddddd... Msgbox("","", $current_song_names & @CRLF & $last_query_PC_name & @CRLF & $last_query_time) Func query() some code ppppp... $current_song_names &= FileRead("c:\current_song_name.txt") & @CRLF $last_query_PCname = @ComputerName $last_query_time = @HOUR & ":" & @MIN & ":" & @SEC some code qqqqq... EndFunc
How would you do it instead?