Relative Content

Tag Archive for tcl

Borrow another class methods in TclOO

In TclOO if I want to borrow only particular method from the other class I just copy it with info class definition class method. But maybe there is more elegant way to do that?
Thank you in advance.

Extend standard puts command for special objects as an argument in Tcl

Is it possible to override behavior of standard command when it accepts TclOO objects as an argument?
The idea is that: I create instance of particular class, and when I do puts $thisObject it does not return the object reference but the special form as combination of internal data members (state) of this objects. So I don’t need a special method to print this state string, this way it works with built-in structures like dict as I understand.
Is it possible? Thank you in advance!

saving and restoring all local and env variables in Tcl

In an overly complex tcl file, I want to save all local and env variables in a file before sourcing anotehr tcl script and once the script finishes I want to restore all the local and env variables. Something like this:

Tclkit/Starkit with shared library on ubuntu

In my tcl tool I use binary shared library in form of file .so + pkgIndex.tcl, then I use package require to load the actual package. It works perfectly fine on my machine, but when I try to pack it into Starpack, it throws me the error when I try to load that package: couldn't load file "/tmp/tcl_MI8NvK":/tmp/tcl_MI8NvK: undefined symbol: Tcl_AppendResult
The rest of the program in pure tcl works fine.
Looks like I missed some important library there, but not sure which one.
If I compile my shared library with inclusion of /usr/lib/x86_64-linux-gnu/libtcl8.6.a
it gives me another error:
couldn't load file "/tmp/tcl_4cwr95":/tmp/tcl_4cwr95: undefined symbol: inflate.

How to check if package is loaded from local dir, not system in Tcl

The question is – I have local copies of some packages from tcllib, and I have tcllib installed globally in /usr/lib/tcllib2.0. How to make sure that my program loads local packages instead of packages from /usr/lib/tcllib2.0? The only way to check that for now is to remove tcllib from the system and append auto_path with my local path (or alter auto_path).
But maybe there is way to check the packages that were loaded are actually loaded from my local folder.
Thank you in advance, George.

How to point multiple aliases to the same executable in TCL?

I’m trying to write a modulefile to load a program, and I would like to include multiple aliases users can call the program with, as they know it under different names. How can I modify this command for setting a single alias to point multiple aliases towards the same executable?