leuce Posted December 1, 2019 Share Posted December 1, 2019 (edited) Hello everyone Is there a way in AutoIt to make the value of a variable automatically update when any of the other variables that form part of its definition get updated? Here's what I mean: $a = 2 $b = $a + 1 ; now $b is 3 $a = 5 ; now I want $b to be 6 (because $b = $a + 1) MsgBox (0, "", $b, 0) ; but no, $b is still only 3 Thanks! Samuel Edited December 1, 2019 by leuce Link to comment Share on other sites More sharing options...
Nine Posted December 1, 2019 Share Posted December 1, 2019 Not by default. But you could use Scripting.Dictionnary to hold your definitions. And then have a function that uses Execute and Assign to apply all the definitions on a variable change. Doable, require some work tho... “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...
_Vlad Posted December 1, 2019 Share Posted December 1, 2019 (edited) Hello there, AdlibRegister would help for that. Check the Console to see the result. HotKeySet('{ESC}', _Exit) $a = 2 $b = $a + 1 ; now $b is 3 $a = 5 ; now I want $b to be 6 (because $b = $a + 1) AdlibRegister('Update', 1000) ;1000 = 1 Second While 1 WEnd Func _Exit() Exit EndFunc Func Update() $b = $a + 1 ConsoleWrite(@CRLF & $b & @CRLF) ;@CRLF - USED FOR A NEW ROW EndFunc Edit : Press ESC to Exit. Edited December 1, 2019 by _Vlad Press ESC to Exit. Link to comment Share on other sites More sharing options...
jchd Posted December 1, 2019 Share Posted December 1, 2019 @leuce Much robust and simple: make that a function. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Nine Posted December 1, 2019 Share Posted December 1, 2019 On a single definition, there is no issue. But let's say he has few hundreds of those definitions that he wants to follow on. Then it can become quite a challenge. “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...
jchd Posted December 1, 2019 Share Posted December 1, 2019 OK but let's start with one. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Nine Posted December 1, 2019 Share Posted December 1, 2019 6 hours ago, jchd said: OK but let's start with one. You have a hard time with someone telling you differently. Kind of annoying you know ? “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...
jchd Posted December 2, 2019 Share Posted December 2, 2019 In this particular case I guessed a simple and clear solution was preferable. You have your right to think otherwise. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Zedna Posted December 2, 2019 Share Posted December 2, 2019 (edited) Global $b $a = A(2) $b = $a + 1 ; now $b is 3 $a = A(5) ; now I want $b to be 6 (because $b = $a + 1) MsgBox (0, "", $b, 0) ; but no, $b is still only 3 Func A($value) $b = $value + 1 Return $value EndFunc EDIT: This is fixed version Global $b $a = A(2) ; now $b is 3 $a = A(5) ; now I want $b to be 6 (because $b = $a + 1) MsgBox (0, "", $b, 0) ; but no, $b is still only 3 Func A($value) $b = $value + 1 Return $value EndFunc Edited December 2, 2019 by Zedna pixelsearch 1 Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
pixelsearch Posted December 2, 2019 Share Posted December 2, 2019 (edited) < deleted by myself, the example I proposed didn't really answer OP's question> Edited December 2, 2019 by pixelsearch Link to comment Share on other sites More sharing options...
leuce Posted December 16, 2019 Author Share Posted December 16, 2019 Thanks, everyone, for your answers. Link to comment Share on other sites More sharing options...
junkew Posted December 17, 2019 Share Posted December 17, 2019 https://www.autoitscript.com/autoit3/docs/functions/Execute.htm Is probably what you want but will depend on your requirements $a = 2 $b = "$a + 1" ; now $b is 3 $a = 5 ; now I want $b to be 6 (because $b = $a + 1) MsgBox (0, "", execute($b), 0) ; but no, $b is still only 3 FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets 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