Unset a variable in tcl

Altair Forum User
Altair Forum User
Altair Employee
edited October 2020 in Community Q&A

Dear friends,

I am using following script to unset a variable but unable to do so. if u change the content of file (del1.txt) it should be reflected in window.

Help me in solving this problem,

Thanks in advance,

mandar

script:

cd 'C:/Altair/hw8.0sr1/hm/bin/WIN32'

set infile [open 'del1.txt' r]

gets $infile line

set y1 [lindex $line 0 ]

close $infile

hwt::CreateWindow check11 \

-windowtitle 'Modify check' \

-noGeometrySaving \

-acceptButton MOD \

-acceptFunc mod \

-minsize 25 100 \

-post;

set recess [hwt::WindowRecess check11];

set f1 [frame $recess.f1];

pack $f1 -side top -anchor nw;

set e1 [hwt::AddEntry $f1.e1 \

-label 'check name:' \

-labelWidth 20 \

-entryWidth 15 \

-state normal \

-anchor nw \

-withoutpacking];

pack $e1 -side top -anchor w ;

EntryInsert $e1 $y1

[ ::hwt::Ent $e1 ] configure -textvariable ::hwt::Check111

proc ::hwt::mod {Args} {

UnpostWindow check11

tk_messageBox -message '$::hwt::Check111 '

unset -nocomplain ::hwt::Check111

tk_messageBox -message '$::hwt::Check111 '

}

Answers

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited January 2008

    Hi mandar,

    I don't understand completely what you want to do. If you want to check for a changed contents of your file, you can invoke a tcl 'after' loop:

    proc readFile {} { global y1 set infile [open 'del1.txt' r] gets $infile line set y1 [lindex $line 0 ] close $infile}proc checkChange {} { readFile puts $::y1 after 1000 checkChange ;# every 1000ms the contents will be updated}

    This is not a very elegant method but works. As I said - I don't know what you want to achieve exactly...

    Greetings

    Thomas