Jump to content

Get var name in a string


Recommended Posts

Does anybody know how can i get a variable name as a string?I've found IsDeclared,Eval,etc,but i haven't found a way to recover the var name to use with them.

Thank you.

Recover the var name...? :D

What exactly are you trying to accomplish?

:P

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I'm trying to make an multidimensional ArrayAdd,using Execute() to ReDim it so i can do it with any number of dimensions.

I don't get it. If the array is passed to the fucntion ByRef, you only need the local name inside the function. If the array is passed ByVal, then you only need to know the local name of the parameter that received it, then Return it. Why do you need the original variable name inside your function? What requires calling the function from Execute()?

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I don't get it. If the array is passed to the fucntion ByRef, you only need the local name inside the function. If the array is passed ByVal, then you only need to know the local name of the parameter that received it, then Return it. Why do you need the original variable name inside your function? What requires calling the function from Execute()?

:D

You have to use Execute to account for a large number of dimensions, due to the lack of OOP.

http://www.autoitscript.com/forum/index.ph...ultidimensional

Link to comment
Share on other sites

You have to use Execute to account for a large number of dimensions, due to the lack of OOP.

http://www.autoitscript.com/forum/index.ph...ultidimensional

Wow, that's an interesting idea. It leads to an interesting feature, too. There's an error in that code:

;Loop through all elements within the current dimension
    For $X = 0 to Ubound($smdArray, $smdDepth)

    ; ...

    Next

Hmm...

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

It works though, I see no errors.

Well, that line quoted should have been: For $X = 0 to Ubound($smdArray, $smdDepth) - 1

It's wrong, but the problem is masked by the Execute() preventing the expected error, so the function works. If Execute() ever gets changed to allow the same array reference errors you would normally get making it directly, then your function will fail also.

:D

P.S. That doesn't change the fact that you wrote a very cool function with a very cool use of Execute() in it...

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Well, that line quoted should have been: For $X = 0 to Ubound($smdArray, $smdDepth) - 1

It's wrong, but the problem is masked by the Execute() preventing the expected error, so the function works. If Execute() ever gets changed to allow the same array reference errors you would normally get making it directly, then your function will fail also.

:D

P.S. That doesn't change the fact that you wrote a very cool function with a very cool use of Execute() in it...

I would fix it if I could ever find a use for its output. Unfortunately, not having OOP syntax for arrays forces the usage of Execute(). Nested arrays are an alternative but you still have to work with a limited amount of dimensions to avoid Execute(). The more I think about it, I feel its a waste of time to accomodate an infinite number of dimensions. Maybe its better to use an array of scripting dictionary objects?

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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