Sign in to follow this  
Followers 0
VIP

Help Replace Var (Get the name of the variable)

14 posts in this topic

Au3 file:

Local $VarToNumber = "123456789"
Local $VarToNameNeedGet= "987654321"

Dim $OtherVar=ReNumber($VarToNumber)
Dim $VarOther=ReNumber($VarToNameNeedGet)

ConsoleWrite($OtherVar & @CRLF)
ConsoleWrite(ReNumber($VarToNameNeedGet) & @CRLF)

Func ReNumber($sVarToNumber)
    Return Number($sVarToNumber)
EndFunc
Find all:

ReNumber($VarToNumber)
ReNumber($VarToNameNeedGet)
Copy Calculator function into the current script! (before):

Func ReNumber($sVarToNumber)
    Return Number($sVarToNumber)
EndFunc
 

Replace:

ReNumber($VarToNumber) -> 123456789

ReNumber($VarToNameNeedGet) -> 987654321

Results:

Local $VarToNumber = "123456789"
Local $VarToNameNeedGet= "987654321"

Dim $OtherVar="123456789"
Dim $VarOther="987654321"

ConsoleWrite($OtherVar & @CRLF)
ConsoleWrite("987654321" & @CRLF)

Func ReNumber($sVarToNumber)
    Return Number($sVarToNumber)
EndFunc

Regards,
 

Share this post


Link to post
Share on other sites



that is correct.

what is your question?

Share this post


Link to post
Share on other sites

that is correct.

what is your question?

Get name of Variable when it access Functions!

 

Local $ThistText = "ValueOfVar" 

ConsoleWrite(respond($ThistText) & @CRLF) 

Func respond($sVar)     
    Return "$sVar"
EndFunc

; Need it =>> $ThistText

Regards,
 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Local $ThisText = "ValueOfVar"

ConsoleWrite(_GetVarName("$ThisText") & @CR)

Func _GetVarName($sVar)
    Return $sVar & ' = "' & Eval(StringTrimLeft($sVar, 1)) & '"'
EndFunc   ;==>_GetVarName

Not something I need!

_GetVarName($ThisText)
Edited by Trong

Regards,
 

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

If you pass the variable to the argument of the function, you get the contents of the variable. For the name you need to pass has string.

Don't quote if is unecessary.

Edited by johnmcloud

Share this post


Link to post
Share on other sites

If you pass the variable to the argument of the function, you get the contents of the variable. For the name you need to pass has string.

Don't quote if is unecessary.

I need name of variable, not contents of variable.

 

_GetVarName($(Random(111111111,999999999999)))

Regards,
 

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

I have understand but i think you don't have understand what i'm say at my previus post...anyway there is any REAL reason why you need the name of the variable?

Edited by johnmcloud

Share this post


Link to post
Share on other sites

I have understand but i think you don't have understand what i'm say at my previus post...anyway there is any REAL reason why you need the name of the variable?

#1

a file like this:

Local $VarToNumber = "123456789" 
Local $VarToNameNeedGet= "987654321" 
Dim $OtherVar=ReNumber($VarToNumber) 
Dim $VarOther=ReNumber($VarToNameNeedGet) 
ConsoleWrite($OtherVar & @CRLF) ConsoleWrite(ReNumber($VarToNameNeedGet) & @CRLF) 

Func ReNumber($sVarToNumber)     
    Return Number($sVarToNumber) 
EndFunc
Need to calculate and replace all the variables!

Regards,
 

Share this post


Link to post
Share on other sites

Trong,

Need to calculate and replace all the variables!

 

We are having trouble understanding what you want to do.

A variable local to a function has no relation to anything outside the function, in fact, only exists within the function.  As far as I know there is no way for a function to know what variable was used as a parameter unless you tell it, like johnmcloud did...

Local $VarToNumber = "123456789"
Local $VarToNameNeedGet= "987654321"
Dim $OtherVar=ReNumber($VarToNumber)
Dim $VarOther=ReNumber($VarToNameNeedGet)
ConsoleWrite($OtherVar & @CRLF)
ConsoleWrite(ReNumber($VarToNameNeedGet) & @CRLF)

Func ReNumber($x)
    Return Number($x)
EndFunc

It might help if you defined what you are trying to do and use a translator.

1 person likes this

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

Trong, AutoIt does not have the function you are looking for. better explain what is your purpose, so we can help you find the way to accomplish it.

1 person likes this

Share this post


Link to post
Share on other sites

My translater cant describe my wish.

Thanks for your help!


Regards,
 

Share this post


Link to post
Share on other sites

What is your native language?  Maybe one of the other members can help.


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

What is your native language?  Maybe one of the other members can help.

Vietnamese

Dịch thuật viên của tôi không hiểu điều tôi muốn nói, nó không phải chuyên ngành của cô ấy.

Tôi muốn lấy tên của Biến vào khi truy xuất vào Hàm. Không phải nội dung của Biến.

Edited by Trong

Regards,
 

Share this post


Link to post
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
Sign in to follow this  
Followers 0