How to access a TK-variable from newlisp?

For the Compleat Fan
Locked
HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

How to access a TK-variable from newlisp?

Post by HPW »

I want to access TK-variables

Code: Select all

> (tk "set test 123")
"123"
> (tk "set test")

> 
When I do the second I get a message window 'can't read "test": no such variable'. On a native TCL-console it works in that way. It respond with the content of the variable. Would be usefull to access all the global vars 'Ide(xxxxxxx)'

Any hints?
Hans-Peter

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

Thanks for posting all these improvements in the Tcl.Tk code. About setting variables in Tcl/Tk: I just try to avoid it and work with the return values from the 'tk' statement stored in LISP variables.

To declare Tcl variables from newLISP, I think you would have to create a child interpreter. But I never went much into Tcl/Tk and newlisp-tk.tcl is the only program in Tcl/Tk I have ever written.
I have only used the 'tk' call. And I want not declare them, I want read and write to existing vars. Ok my test was a new var, but it also works not with the existing one's from the config-file.
Hans-Peter

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

try this:

(tk "global Ide; set Ide(fontSize)")

or this:

(tk "global Ide; set Ide(fontSize) 16")

Then open a editor/browser window ;)

Lutz

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

Lutz,

thanks for the hint.
I had thought that it could be a problem with the scope of the vars.
I had tried around, but with no satisfying solution.
So this is short and easy.
Fits very good in the concept of newlisp. :-)
Hans-Peter

Locked