millisys Posted May 20, 2013 Share Posted May 20, 2013 Hi all, I have created a variable ($results) to contain variables to write to a CSV file. The variables are assigned many times throughout the script. I noticed that the $var1,$var2,$var3 variables inside the $results variable to be written to the CSV file are not acknowledging the values if they occur after the $results declaration in the script. Probably an example will better explain. Is there a way to 'refresh' the $results variable before it writes so that it can capture values from later variables? I looked at ReDim but that seems to be only for arrays. Thank you $var1 = 0 $var2 = 0 $var3 = 0 $results = $var1 & "," & $var2 & "," & $var3 $var1 = 1 $var2 = 2 $var3 = 3 ConsoleWrite($results) Link to comment Share on other sites More sharing options...
jdelaney Posted May 20, 2013 Share Posted May 20, 2013 (edited) variable assingments are static, you would need to redeclare $results with the new $var1 & "," & $var2 & "," & $var3 It seems that you can create a function, and just call with the new values: $var1 = 0 $var2 = 0 $var3 = 0 $yourvariable = SomeFunc($var1,$var2,$var3) MsgBox(1,1,$yourvariable) $var1 = 1 $var2 = 2 $var3 = 3 $yourvariable = SomeFunc($var1,$var2,$var3) MsgBox(1,1,$yourvariable) $yourvariable = SomeFunc(5,6,7) MsgBox(1,1,$yourvariable) Func SomeFunc($1,$2,$3) ConsoleWrite($1 & "," & $2 & "," & $3 & @CRLF) Return $1 & "," & $2 & "," & $3 EndFunc Exit Edited May 20, 2013 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Solution millisys Posted May 20, 2013 Author Solution Share Posted May 20, 2013 Thank you jdelaney. Good idea! I will go with creating a function to redeclare the $results internal variables. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now