Jump to content

Recommended Posts

Posted (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 by leuce
Posted

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

Posted (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 by _Vlad
Press ESC to Exit.
Posted

@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 here
RegExp tutorial: enough to get started
PCRE 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)

Posted

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 here
RegExp tutorial: enough to get started
PCRE 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)

Posted

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 here
RegExp tutorial: enough to get started
PCRE 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)

Posted (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 by Zedna
Posted (edited)

< deleted by myself, the example I proposed didn't really answer OP's question>

Edited by pixelsearch

"I think you are searching a bug where there is no bug... don't listen to bad advice."

  • 2 weeks later...

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
  • Recently Browsing   0 members

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