Jump to content

Help Replace Var (Get the name of the variable)


Trong
 Share

Go to solution Solved by orbs,

Recommended Posts

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,
 

Link to comment
Share on other sites

that is correct.

what is your question?

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
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,
 

Link to comment
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,
 

Link to comment
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.

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

Link to comment
Share on other sites

  • Solution

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.

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

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,
 

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