Sign in to follow this  
Followers 0
jvanegmond

Code that checks wether a value in variable has changed.

1 post in this topic

#1 ·  Posted (edited)

This probably exists. I thought of this last night when i went to bed.

Edit: I build this because i've had need for this in the past, but always solved it in a fixed way. The generic way is the better one imo.

; ----------------------------------------------------------------------------
; AutoIt Version: 3.1.0
; Author:        Jos van Egmond (Manadar) <>
;
; Script Function:
;   Example, with function, of Change.
;   Use this as If Change("hello") Then MsgBox(0,"Alert", "$hello has changed");
; ----------------------------------------------------------------------------

$i = 0

While 1
    $i += random(0,1,1)
    If Change("i") Then;variable name in string without $
        MsgBox(0, "Alert", "$i has changed $i = "&$i)
    Else
        MsgBox(0, "Alert", "$i has NOT! changed $i = "&$i)
    EndIf
WEnd

Func Change($var)
    If IsDeclared($var&"_variable_copy") Then
        If Eval($var) == Eval($var&"_variable_copy") Then
            Assign($var&"_variable_copy",Eval($var),0)
            Return 0
        Else
            Assign($var&"_variable_copy",Eval($var),0)
            Return 1
        EndIf
    Else
        Assign($var&"_variable_copy",Eval($var),2)
        Return 0
    EndIf
EndFunc
Edited by Manadar

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