Re: activestate"s Tcl.pm question

Re: activestate"s Tcl.pm question

am 01.04.2008 13:54:14 von Janwillem Borleffs

~greg schreef:
> this ...
> use Tcl;
> my $Interpreter = new Tcl;
> $Interpreter->Eval('puts "Hello world"');
> $Interpreter->Eval('puts $auto_path');
>
> puts this ...
>
> Hello world
> can't read "auto_path": no such variable at ...\test.pl line 4.
>

I have never used this module, but it seems that the problem is related
to the use of single quotes; try instead:

$Interpreter->Eval("puts $auto_path");


JW

Re: activestate"s Tcl.pm question

am 04.04.2008 06:33:13 von g_m

"Janwillem Borleffs" wrote in message news:47f22266$0$3012$dbd4d001@dr5.euro.net...
> ~greg schreef:
>> this ...
>> use Tcl;
>> my $Interpreter = new Tcl;
>> $Interpreter->Eval('puts "Hello world"');
>> $Interpreter->Eval('puts $auto_path');
>>
>> puts this ...
>>
>> Hello world
>> can't read "auto_path": no such variable at ...\test.pl line 4.
>>
>
> I have never used this module, but it seems that the problem is related
> to the use of single quotes; try instead:
>
> $Interpreter->Eval("puts $auto_path");



No.
But thank you anyway.
~~

It's tcl syntax in that Eval(), not perl syntax.

If you think about it, perl wouldn't call that kind of error.
If you
print 'puts $auto_path';
in perl, you'd simply get
$auto_path.
because Perl doesn't interpolate variables in single quotes.

Like perl, tcl also uses '$' for variables
(but only to get the value (R-side), and not for setting it (L-side)).

This, for example, works fine: ...
use Tcl;
my $Interpreter = new Tcl;
$Interpreter->Eval('set x "Hello world"');
$Interpreter->Eval('puts $x');

It prints
Hello world

~~
Actually what I wanted was to get Tkx.pm to use Activestate's Tcl/Tk
installation instead of the tkkit.dll that they ship with Tkx.pm
(If you follow me. But don't worry if you don't. This is not a very popular subject.)

I only mentioned Tcl.pm because I knew that Tkx.pm uses Tcl.pm,
so I thought it'd be easiest (or necessary) to get Tcl.pm to use Tcl/Tk first.

And I did finally get Tkx to use Tcl/Tk,
(in the sense that
use Tkx;
print join "\n", (Tkx::SplitList(Tkx::set('auto_path')));

now prints out
C:/Tcl/lib/tcl8.5
.... etc )


However, trying it again, I still can't get
use Tcl;
my $Interpreter = new Tcl;
$Interpreter->Eval('puts $auto_path');

to print anything but:
can't read "auto_path": no such variable at ...

Which means I don't really understand how these things
(Tkx.pm, Tcl.pm, Tcl/Tk, tkkit.dll) are actually hooked up.


~greg

Re: activestate"s Tcl.pm question

am 04.04.2008 06:40:19 von g_m

correction --
> If you
> print 'puts $auto_path';
> in perl, you'd simply get
> puts $auto_path.