Tyranna Posted July 18, 2018 Share Posted July 18, 2018 (edited) Global $Active0 , $Active1 , $Active2 $array[3][3] = [ _ [ "Tyranna" , $Active0 , "My Street ] , _ [ "AutoIt" , $Active1 , "Your Street" ] , _ [ "Version3" , $Active2 , "Their Street ]] Func Main() $Active0 = 1 $Active1 = 0 $Active2 = 1 Output() EndFunc Func Output() For $i = 0 to 2 For $i = 0 to 2 ConsoleWrite( $array[$i][0] , $array[$i][1] , $array[$i][2] ) Next Next EndFunc I want to be able to access the current value of a variable through an array element somewhat like this. The middle array element when accessed needs to return the current value of the variable. Is there a way to say "value of" array[0][1] , "value of" array[1][1], "value of" array[2][1] ? Edited July 18, 2018 by Tyranna Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted July 18, 2018 Share Posted July 18, 2018 7 minutes ago, Tyranna said: Is there a way to say "value of" array[0][1] , "value of" array[1][1], "value of" array[2][1] ? For $i = 0 To UBound($arrSomeArray) - 1 ConsoleWrite("The value of " & "$arrSomeArray[" & $i & "][1] is " & $arrSomeArray[$i][1] & @CRLF) Next Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Tyranna Posted July 18, 2018 Author Share Posted July 18, 2018 That displays the current value of the array element , not the current value of the varible , which is what i want to capture. Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted July 18, 2018 Share Posted July 18, 2018 (edited) How is your array made? The one in the first post has only one variable, and it is at index 1 of the array ( $Active0 ). Edited July 18, 2018 by FrancescoDiMuro Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Earthshine Posted July 18, 2018 Share Posted July 18, 2018 (edited) whatever it is, it doesn't compile even. on top of that, when i got it to compile your loop has array dimension errors. Edited July 18, 2018 by Earthshine Fin 1 My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
Tyranna Posted July 18, 2018 Author Share Posted July 18, 2018 Well , maybe I am not clear. What I am trying to do is access the current value of the $Active variables by accessing an array element. I am creating or reading in the array first and then changing the variable values and want to access the new values by accessing the array elements. I want to somehow link the array element and the CURRENT variable value without reloading the array. Maybe making the array element a pointer to the other variable. Not sure exactly how. Link to comment Share on other sites More sharing options...
Tyranna Posted July 18, 2018 Author Share Posted July 18, 2018 Yeah i got a subscript wrong on the loop index , sorry Link to comment Share on other sites More sharing options...
Earthshine Posted July 18, 2018 Share Posted July 18, 2018 I think there is a UDF for such things, check out @LarsJ stuff. Have a search on the forum for the array stuff, I think you can make arrays of objects My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
Earthshine Posted July 18, 2018 Share Posted July 18, 2018 here it is. I think what you want may be in that. My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
Tyranna Posted July 18, 2018 Author Share Posted July 18, 2018 That is about speed of access, what I am really looking for is: The statement $temp = array[0][1] to return the value of $Avtive0 , not the contents of the array element. Link to comment Share on other sites More sharing options...
Earthshine Posted July 18, 2018 Share Posted July 18, 2018 (edited) you might need to look into this this isn't C so don't expect any miracles. No pointers here. Edited July 18, 2018 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
Tyranna Posted July 18, 2018 Author Share Posted July 18, 2018 Yeah , I have seen that one before , but I really do not want to jump through a dozen hoops to get a variable value. What about making the Array element a string , and doing some kind of expansion on it ? Seems like I have seen something like that before... Link to comment Share on other sites More sharing options...
Earthshine Posted July 18, 2018 Share Posted July 18, 2018 I don 9 minutes ago, Tyranna said: Yeah , I have seen that one before , but I really do not want to jump through a dozen hoops to get a variable value. you may not have much choice here except to write it in C or C++ My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
BrewManNH Posted July 18, 2018 Share Posted July 18, 2018 Try this: Global $Active0, $Active1, $Active2 Global $array[3][3] = [["Tyranna", "Active0", "My Street "], ["AutoIt", "Active1", "Your Street"], ["Version3", "Active2", "Their Street "]] Main() Func Main() $Active0 = 1 $Active1 = 0 $Active2 = 1 Output() EndFunc ;==>Main Func Output() For $i = 0 To 2 ConsoleWrite("$Active" & $i & " = " & Eval($array[$i][1]) & @CRLF) Next EndFunc ;==>Output Earthshine and Fin 2 If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Earthshine Posted July 18, 2018 Share Posted July 18, 2018 (edited) very nice @BrewManNH Edited July 18, 2018 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
Tyranna Posted July 18, 2018 Author Share Posted July 18, 2018 This is the ANSWER! Thanks. Looks like all you have to do is remove the $ from the front of the variable name in the array , and EVAL grabs the global variables value... I just tested it and it seems to run correct . All smiles now. 8) Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted July 18, 2018 Share Posted July 18, 2018 @Tyranna The @BrewManNH solution is what I was saying... Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Malkey Posted July 19, 2018 Share Posted July 19, 2018 If this is what you were after in BrewManNH's example, ConsoleWrite("$Active" & $i & " = " & Eval($array[$i][1]) & @CRLF) then this does the same thing (in BrewManNH's example). ConsoleWrite("$Active" & $i & " = " & Execute("$" & $array[$i][1]) & @CRLF) Earthshine 1 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