Re: ReadList[file,HeldExpression] ?
- To: mathgroup at smc.vnet.net
- Subject: [mg67633] Re: ReadList[file,HeldExpression] ?
- From: dh <dh at metrohm.ch>
- Date: Mon, 3 Jul 2006 06:37:31 -0400 (EDT)
- References: <e85ful$kf8$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi Mark,
1) read your file as strings to prevent evaluation
2) convert the strings to expressions and wrap these into Hold:
ToExpression[..,InputForm,Hold]
E.g.:
ToExpression[ ReadList["FileName", "String"], InputForm, Hold]
Daniel
Mark wrote:
> Can someone tell me how to do the following?
>
> Say I have a Mathematica file go.m with the following two lines:
>
> a=2;
> c = 3;
>
> and I want a command ReadCommandsInFile such that
> ReadCommandsInFile["go.m"] produces
>
> {Hold[Set[a,2]],Hold[Set[c,3]]}
>
> but I do not want to execute these commands.
>
> Mark
>