From: Maurice L. <mj...@ga...> - 2002-02-19 22:27:21
|
Geoffrey Furnish writes: > Alan W. Irwin writes: > > I have been struggling with resetting the cmap1 to default values for tcl. > > Turns out my problems were due to the following construct which I thought > > should work to initialize the matrix. > > > > matrix l f 6 = {0.5, $midpt, $vertex, $vertex, $midpt, 0.5} > > > > This silently fails by sticking zeroes everywhere there is a variable > > reference (i.e., all the interior points) even though the variables have > > previously been set. Isn't this a bug? Shouldn't the variables just be > > replaced by their values? > > > > I worked around this by using > > > > l 1 = $midpt > > l 2 = $vertex > > > > etc., in x08.tcl, > > > > but I don't think this workaround should be necessary. > > :-). It's called "Tcl" because you're supposed to giggle every time > it annoys you. > > Braces protect against variable interpolation. > > There's probably a way to get what you want using eval or list or > something. The matrix initializer is expecting a Tcl list for input. So if you want variables expanded, use quotes, not braces. Unfortunately quotes are cumbersome for initializing a multidimensional array (if even this works; it looks like it might but I haven't tried). So ideally the initializer would call Tcl_ExprDouble or Tcl_ExprLong in order to evaluate the arguments. I'll put it on my list of things to consider in my Tcl matrix overhaul planned for later this year, but otherwise try using quotes. -- Maurice LeBrun mj...@ga... |