Jump to content

Recommended Posts

Posted (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 by Tyranna


 

Posted

That displays the current value of the array element , not the current value of the varible , which is what i want to capture.

 


 

Posted (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 by Earthshine

My resources are limited. You must ask the right questions

 

Posted

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.


 

Posted

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

 

Posted

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.

 


 

Posted (edited)

you might need to look into this

this isn't C so don't expect any miracles. No pointers here.

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Posted

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...


 

Posted

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

 

Posted

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

 

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 Gude
How 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

Posted

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)


 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...