RE: Variable containing code

*To*: mathgroup at smc.vnet.net*Subject*: [mg74978] RE: [mg74937] Variable containing code*From*: "Ingolf Dahl" <ingolf.dahl at telia.com>*Date*: Fri, 13 Apr 2007 02:05:58 -0400 (EDT)*Organization*: Goteborg University*References*: <200704120847.EAA24473@smc.vnet.net> <001301c77ceb$d0454d70$70cfe850$@dahl@telia.com> <461E09C2.7020003@metrohm.ch>*Reply-to*: <ingolf.dahl at telia.com>

Hi Daniel, The easiest way I could come up with fast is this: Use t1[1] instead of t1: t1[1]:= Print["Hello"] Use a storage variable: store = DownValues[t1]; Put then t2 := store[[1, 2]] Then you could change t1, and t2 will anyway print "Hello" each time you evaluate it. There are probably better ways. Best regards Ingolf Dahl -----Original Message----- From: Daniel Huber [mailto:dh at metrohm.ch] Sent: 12 April 2007 12:28 To: ingolf.dahl at telia.com Subject: [mg74978] Re: [mg74937] Variable containing code Hi Ingolf, unfortunately life is not so easy. t2:=t1 reevaluates t1 each time t2 is used. If t1 is changing in between t2 is changed too. What is looked for, is a way to get the value of t1 into the definition of t2 without evaluating it. Daniel Ingolf Dahl wrote: > Maybe you could try with > > t2 := t1; > > or am I missing something? > > Best regards > > Ingolf Dahl > Sweden > > -----Original Message----- > From: dh [mailto:dh at metrohm.ch] > Sent: 12 April 2007 10:47 > To: mathgroup at smc.vnet.net > Subject: [mg74937] Variable containing code > > > > Hello, > > how can one get at the value of a variable if this value is executable > > code? E.g. consider variable t1:= Print["Hello"]. How can I set the > > value of a second variable t2 to the value of t1 without executing the code? > > Daniel > > > > > > > > -- Daniel Huber Metrohm Ltd. Oberdorfstr. 68 CH-9100 Herisau Tel. +41 71 353 8585, Fax +41 71 353 8907 E-Mail:<mailto:dh at metrohm.ch> Internet:<http://www.metrohm.ch>

**References**:**Variable containing code***From:*dh <dh@metrohm.ch>