(sorry if this is a FAQ, but I couldn't find an answer on the wiki page)
Is there a guide how to upgrade an old Tcl/Tk application to Tcl/Tk 8.5?
Is there a (semi-)automatic way to do it?
Many thanks for a hint,
Helmut Jarausch
Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany
There is no guide in the sense of a cookbook, where you can find
explanations on how to change your script. All scripts, that work in
the current 8.4 release should run in 8.5 without modifications
(someone correct me, if this is wrong).
What you can find on th wiki is this:
This is a list with all the changes and enhancements for 8.5. Using
this as a guideline, you should be able to get an overview of the
wealth of new stuff and subsequently update old scripts.
Torsten
Almost all will. Scripts that depend on the exact behaviour of cursor
motion in the [text] widget may have problems, as may scripts that
depend on details of font handling. Oh, and you're SOL if you're on
Mac Classic. :-)
As always, it's not a good idea to write scripts that depend on
formats of particular error messages.
Donal.
Helmut Jarausch wrote:
> Hi,
>
> (sorry if this is a FAQ, but I couldn't find an answer on the wiki page)
>
> Is there a guide how to upgrade an old Tcl/Tk application to Tcl/Tk 8.5?
Depends how old and how deep you reach into the Tcl/Tk internals.
Basic rules:
If you use only tcl.h, tk.h and the exported functions from the stubs
table your quite safe.
If you go from 8.4 to 8.5 it should be easy, simply recompile.
If you go from 8.x x <4 to 8.5 you may need to fix some CONST stuff
that changed in 8.4.
(see http://wiki.tcl.tk/3669)
If you go from 7.x to 8.5 you can expect some more work.
But:
If you use tclInt.h or other non public interfaces all bets are
off..., try to recompile and see where the compiler bitches.
Michael
That is (would be) good news.
But my very first test failed, trying
xtem from
http://www.ctan.org/tex-archive/support/xtem_texmenu/xtem/?action=/tex-archive/support/xtem_texmenu/
I get (when pressing the exit button)
bad variable name "geom(.xtemqd)": upvar won't create a scalar variable that
looks like an array element
while executing
"global [set var]"
(procedure "writeVarList2File" line 5)
invoked from within
"writeVarList2File $vst_file $vstWListe "geom prtcmd""
(procedure "vstWriteFile" line 16)
invoked from within
"vstWriteFile $vf"
invoked from within
".a.1.e invoke"
("uplevel" body line 1)
invoked from within
"uplevel #0 [list $w invoke]"
(procedure "tk::ButtonUp" line 22)
invoked from within
"tk::ButtonUp .a.1.e"
(command bound to event)
Sorry, I don't know Tcl very well,
Here is procedure "writeVarList2File"
proc writeVarList2File {file list globl} {# write variable names and values of
list into file
TestPut 3 "<$file><$list><$globl>"
if {[catch "open $file w" FID]==0} {
foreach var $globl {global $var}
foreach var $list {global [set var]; eval puts \$FID \"\$var \$$var\"}
close $FID
TestPut 3 "written:<$FID>"
}
}
Many thanks for your help,
Helmut.
--
This statement used to be "useless": it would have created a variable
that is completely unreachable from Tcl code. It is now an error.
What it means is that your code did not really do what you thought it did.
> "global [set var]"
> (procedure "writeVarList2File" line 5)
> invoked from within
> ...
> Sorry, I don't know Tcl very well,
No need to be sorry, let's try to help you improve.
> Here is procedure "writeVarList2File"
> proc writeVarList2File {file list globl} {# write variable names and
> values of list into file
> TestPut 3 "<$file><$list><$globl>"
> if {[catch "open $file w" FID]==0} {
> foreach var $globl {global $var}
> foreach var $list {global [set var]; eval puts \$FID \"\$var \$$var\"}
> close $FID
> TestPut 3 "written:<$FID>"
> }
> }
So: at least one of the elements passed in $list looks like an array
element: "geom(.xtemqd)" -the puts should have failed to list its value.
EXCEPT if the variable "geom" was passed in $globl, or in $list but
before any of its elements. In that case things would have worked
anyway, but not the way you thought.
Or else I am mistaken - it does happen every now and then :)
Quick workaround: catch the global statement:
proc myglobal args {
uplevel 1 [list catch [list global {*}$args]]
}
Good fix 1: remember that you cannot use 'global' nor 'variable' on
individual array elements, make sure you do not try to.
Good fix 2: rewrite that proc, eg like (untested, avoiding 8.5'isms):
proc writeVarList2File {file list globl} {
# write variable names and values of list into file
TestPut 3 "<$file><$list><$globl>"
if {[catch "open $file w" FID]==0} {
# The following line is doing nothing useful?
# foreach var $globl {global $var}
foreach var $list {
upvar #0 $var local
puts $FID "$var $local"
}
close $FID
TestPut 3 "written:<$FID>"
}
}
Note that upvar CAN create a local (scalar!) variable linked to an
individual array element.
HTH
Miguel
Also if you were using the dict as an extension in 8.4, you may want to
remove the package require dict since it is now built into 8.5.
--
+--------------------------------+---------------------------------------+
| Gerald W. Lester |
|"The man who fights for his ideals is the man who is alive." - Cervantes|
+------------------------------------------------------------------------+
Ah yes, and there are a number of significant upgrades for dicts about,
including the fact that 8.5's dicts now preserve the order of the keys,
so making for more stable management of iteration and shimmering. (Note
that this wasn't in 8.5b3.)
Donal.
The one change, I'd consider most likely to surprise anyone (who
didn't follow this group or other ressources during the last few
years), is that integer-operations no longer wrap around at 2^31.
I recently ported a fairly large tcl project to 8.5 and
had two issues that required programming changes.
First, tcl_precision changed and that affected the display
of some numbers. For example,
pack [label .l -textvariable foo]
set foo [expr {2.7 + .6}]
Under 8.4 this displayed 3.3, under 8.5 it shows 3.30000000000003.
I had to fix this by adding additional trace commands and shadow
variables.
Second, grid behavior changed when the widget is smaller than
the container. Tcl 8.5 added the grid anchor command but the
8.5 default is nw while 8.4 behavior was center.
Keith
In addition to advice already offered, take a look at the entries in
the "changes" files that are marked ** POTENTIAL INCOMPATIBILITY **.
--
| Don Porter Mathematical and Computational Sciences Division |
| donald...@nist.gov Information Technology Laboratory |
| http://math.nist.gov/~DPorter/ NIST |
|______________________________________________________________________|
This page should cover incompatibilities at the script level. There
may be other incompatibilities. It is my hope that at the very least,
a page covering additional issues is created at http://wiki.tcl.tk/
which could then be added to 10630 for those undergoing the
transition.
Well, if you were using Tile as an extension in 8.4, there are some
differences, right? I mean, the name space is ttk:: and, depending on
how old your version of the Tile extension is, there may be some
differences.
Also, there may be new errors where one didn't get them before - that
sort of thing is pretty typically in this type of upgrade.