[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Watching a variable (array) for change


Try the shmmem library from the software farm. It allows you to create variables that will raise an event when changed. When created or destroyed. That includes arrays
Hope this helps. once the library is installed, make the executable.
There is a wiki with info:https://github.com/justlostintime/ShmMem/wiki
in your code:
__________________________________________--- cut here _____________________________________
' Gambas module file

Use ":westwood/shmmem:2.2"
Class Shmmem

Public Sub Main()

    Print "hello world"
    Dim mymem As New Shmmem
    Print "Memory defined"

    With mymem
        !a = 1
        !b = "this"
        .notify("b", Me)
        !c = ["this", 2, 3, 4, "that"]
        Print !a, !b, !c
        .["c", 0] = "pull"
        Print !c[0]
        .b = "hellow there i changed"
    End With
    Print "Done"
    mymem.close()
    Quit 0

Catch
    Error "Script Error >";; error.text & "\n" & error.where

End

Public Sub b_changed(varname As String, value As Variant, TimedOut As Boolean)

    Print "b set to :";; value

Catch
    Print "oops user 1";; error.text;; error.where

End
_____________________________________________________________ cut here ________________________________________________________________


On October 28, 2026 11:42:50 PM PDT, BB <adamnt42@xxxxxxxxx> wrote:

   On 26/10/26 7:21 am, Bruce Steers wrote:


    Is is possible to watch a variable for changes?

    I'm trying to do something with TextEditor that reacts when a
    procedure Limit is Collapsed / Expanded
    I've managed to get something working when mouse clicks do it but
    there's other ways to collapse/expand limits too so looking for a
    simpler way.

    I can get a pointer to the TextEditor $aFold variable via the
    TextEditor._GetFolding() method but is there a way to monitor an
    Array and react to any changes?

    I've removed an adapted gb.form.editor source from my program and
    and trying to replace all my mods via auto-inheritance of the main
    component instead.

    I did have a TextEditor Fold event that triggered when a procedure
    was folded/expanded. I'm trying to emulate that.
    Having the Fold event added to master would be good but won't
    really help me with backward compatibility so i'm looking for a
    workaround.

    Respects
    BruceS

   This is not easy. I have been digging down into it and trying to
   find a way to raise a signal where an address is written to at the
   OS level. It is not an easy thing to do, in fact it may be impossible.

   But it has been a bit of a poser to be sure.

   hmmm

   b


Attachment: OpenPGP_0x78BFB26402F48419.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


Follow-Ups:
Re: Watching a variable (array) for changeBrian G <brian@xxxxxxxxxxxxxxxx>
References:
Watching a variable (array) for changeBruce Steers <bsteers4@xxxxxxxxx>
Re: Watching a variable (array) for changeBB <adamnt42@xxxxxxxxx>