I cant run some TCLLib functions
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.tcl archive

I cant run some TCLLib functions

From: Scott Brown <None@invensys.com>
Date: Thu Jun 30 2005 - 00:48:18 CEST

Hello,
I have a TCL 8.4 interpreter embedded in my windows application. The
standard commands (set, lappend, etc) work fine. I can get some of the
library commands to work but most of them do not work. I would greatly
appreciate any help you can provide. Here are some specifics:

I create the interpreter using:

          Tcl_FindExecutable("D:\MyProgram\Server\bin\MAServer.exe");
          m_interp = Tcl_CreateInterp();
          if ( m_interp == NULL ) { print error messages and return }
          Tcl_SetVar2(m_interp , "env", "TCL_LIBRARY",
"D:/MyProgram/Server/TCL84Lib/TCL8.4", TCL_GLOBAL_ONLY);
          Tcl_SetVar2(m_interp , "env", "TCLLIBPATH",
"D:/MyProgram/Server/TCL84Lib/TCL8.4", TCL_GLOBAL_ONLY);
          Tcl_SetVar(m_interp, "argv0", "", TCL_GLOBAL_ONLY); //Needed to
make ::math::statistics::mean work!
          if (Tcl_Init(m_interp) == TCL_ERROR) { print error messages and
return }

To test the libraries I try to run the following TCL script, (which works
fine in tclsh)
          package require math::statistics;
          puts "Mean = [::math::statistics::mean {1 2 3}]";

but I get the following message:
          invalid command name "tclPkgUnknown"
              while executing
          "tclPkgUnknown math::statistics {}"
              ("package unknown" script)
              invoked from within
          "package require math::statistics"
              (procedure "__SampleMacro" line 1)

Then I discovered that the following TCL does work:
          source "[info library]/package.tcl";
          package require math::statistics;
          puts "Mean = [::math::statistics::mean {1 2 3}]";

I don't understand why I need to source the package.tcl file, but I can live
with this workaround. This is probably a clue to the source of my problems.

My next test was to try a different one of the math functions (part of the
math package, not math::statistics):
          source "[info library]/package.tcl";
          package require math;
          puts "StdDev = [::math::sigma 1 2 3 4]";

but now I get the following message
          invalid command name "::math::sigma"
              while executing
          "::math::sigma 1 2 3 4"

Seems like there is something wrong with my environment, path etc.

I would greatly appreciate any help you can give. I have been trying to
solve this problem on and off for 2 weeks.

Thanks,
Scott
Received on Thu Sep 29 14:23:53 2005