MASKED Posted March 4, 2021 Share Posted March 4, 2021 in autohotkey "%" character is using for revert variable to string. also this character can be use with variables.for example in AHK: variable1 := 1 variable2 := 2 Loop{ tmp := variable%A_Index% msgbox , %tmp% if(A_Index = 2){ Break } } Exit this script print "1" and "2" on the screen. then exit is there a thing in autoit what do same work ? help me please and sorry 4 bad english Link to comment Share on other sites More sharing options...
Nine Posted March 4, 2021 Share Posted March 4, 2021 You could do it like this : #include <Constants.au3> Local $variable1 = 1 Local $variable2 = 2 Local $tmp For $i = 1 to 2 $tmp = Eval("variable" & $i) MsgBox ($MB_SYSTEMMODAL, eval("tmp"), $tmp) Next But we usually discourage using this type of assignment. You would probably be better with an array. Local $aArray[2] = [3, 4], $tmp For $i = 0 to UBound($aArray) - 1 $tmp = $aArray[$i] MsgBox ($MB_SYSTEMMODAL, $aArray[$i], $tmp) Next MASKED 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
MASKED Posted March 4, 2021 Author Share Posted March 4, 2021 thanks dear friend. "Eval" does my job. thanks a lot ^^ Link to comment Share on other sites More sharing options...
AspirinJunkie Posted March 4, 2021 Share Posted March 4, 2021 Another variant would be to set the option "ExpandVarStrings": Opt("ExpandVarStrings", 1) Local $variable1 = 1 Local $variable2 = 2 Local $tmp For $i = 1 to 2 $tmp = "$variable" & $i & "$" MsgBox (0, "", $tmp) Next But also here applies what Nine already said: Use arrays instead. MASKED 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