Strommer
Strommer

Reputation: 363

Using classes in TCL using Simple Agent Pro

I am using this software called Simple Agent Pro, and it primarily uses TCL code. I was wondering anybody familiar with TCL or Sapro would be kind enough to tell me how to import the modules into the .tel file for Sapro.

When I try this:

package require tclOO.h

The program stops working. Any help would be appreciated.

Upvotes: 0

Views: 169

Answers (2)

Donal Fellows
Donal Fellows

Reputation: 137577

I don't know Simple Agent Pro at all, but if you're doing a “guerilla install” of TclOO then you need a few things:

  • Make sure you're using Tcl 8.5 (see what package require Tcl returns).
    • If you're using 8.4 (note: 8.4 EOLed this month), TclOO will not work at all (and it cannot be backported).
    • If you're using 8.6, it already provides the TclOO package and you shouldn't need to fuss around with all this.
  • Do a build of TclOO and install it to a location you prefer.
    • This will require Tcl's internal source files; TclOO explicitly pokes its nose into places where most code shouldn't.
    • You probably don't need to have a custom build of 8.5; just the configured sources somewhere will do. (You might need to hack the configure scripts a little bit.)
  • Add the location that you installed TclOO to to the search path inside your Tcl 8.5 program.

    lappend auto_path /the_dir/you_put/it_in
    

    If you're using Windows, it's probably easiest to use forward slashes for this path anyway (this is a directory name that is always highly protected before it hits the OS, so that's OK).

  • Now you should be able to require/use the package.

    package require TclOO
    
    oo::class create Foo {
        # etc.
    }
    

    Note that the case and exactly how you write it matters. The version you get ought to be at least 1.0 (earlier versions were for development only) which corresponds exactly with the API as supported in Tcl 8.6 (modulo a few things that require 8.6 for other reasons, such as being able to yield inside a method which only works in 8.6 because that's where yield was first defined).

Upvotes: 2

Johannes Kuhn
Johannes Kuhn

Reputation: 15163

You probably mean

package require TclOO

Case and other stuff is important there.

Next time you should also include the stack trace. If the program stops working, it should display that either as dialog or on stdout.

Upvotes: 0

Related Questions