loading Units package from a Button in 6.0
- To: mathgroup at smc.vnet.net
- Subject: [mg79393] loading Units package from a Button in 6.0
- From: Hannes Kessler <HannesKessler at hushmail.com>
- Date: Thu, 26 Jul 2007 05:21:23 -0400 (EDT)
Hello,
apparently I discovered a bug when loading the Units package
indirectly via Needs from within a Button environment.
Here is the almost empty package file TestPackage.m which needs the
Units-package:
BeginPackage["TestPackage`", {"Units`"}];
EndPackage[];
Here is the notebook TestPackage_calling.nb with a single input cell
which produces a button. If the button is pressed, the user is
prompted for a file name which should be TestPackage.m in the same
directory.
contextpath := $ContextPath;
Print @ Dynamic @ Column @ {
Button["File",
file =
SystemDialogInput["FileOpen", NotebookDirectory[] <> "\\*.m"];
Needs["TestPackage`", file]
],
Dynamic@file,
Dynamic@contextpath
};
The first time the resulting context path {"Units`", "System`"} is
incomplete. Only pressing the button a second time and loading the
file results in the correct context path {"TestPackage`", "Units`",
"System`"}.
The problem does not occur when invoking SystemDialogInput outside the
Button environment or with other packages than Units. The Units-
package I used is the bugfix supplied by Wolfram Research after
release of Mathematica 6.0 to correct wrong references to the old
Miscellaneous`Units` context (http://support.wolfram.com/mathematica/
packages/units/badunitsconvert.html).
Any suggestions or ideas?
Thanks in advance,
Hannes Ke=DFler