Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Using Block instead of Module?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg24265] Re: Using Block instead of Module?
  • From: "Rasmus Debitsch" <debitsch at Zeiss.de>
  • Date: Wed, 5 Jul 2000 23:10:46 -0400 (EDT)
  • Organization: Customer of UUNET Deutschland GmbH
  • References: <8jtf5f$ik5@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hello,

outputTest[
      lst_List,
      id_Integer] := Module[{
        fname,
        tmp = lst
        },
      fname = ToString[id] <> ".txt";
      Put[tmp, fname];
      ];

does the job.

Regards

--

        Rasmus Debitsch
        Carl Zeiss Lithos GmbH
        Carl Zeiss Strasse
        D-73447 Oberkochen

        eMail : debitsch at zeiss.de

Wen-Feng Hsiao <d8442803 at student.nsysu.edu.tw> schrieb in im Newsbeitrag:
8jtf5f$ik5 at smc.vnet.net...
> Dear listers,
>
> I try to output results to a file whose name is variable, and find Module
> statement cannot fulfill this purpose, only Block can do. For example,
>
> outputTest[lst_List, id_Integer] := Module[{fname, tmp = lst},
>       fname = ToString[id] <> ".txt";
>       ToExpression["tmp >>" <> fname];
>       ];
>
> outputTest[{1, 2, 3}, 3]
>
> The output file is 3.txt, but the content is "tmp". But if I change
> Module statement into Block as below:
>
> outputTest[lst_List, id_Integer] := Block[{fname, tmp = lst},
>       fname = ToString[id] <> ".txt";
>       ToExpression["tmp >>" <> fname];
>       ];
>
> outputTest[{1, 2, 3}, 3]
>
> The output file is 3.txt, and the content is correct, {1, 2, 3}. How if
> one used to use Module, like me, should do for the same purpose?
>
> Wen-Feng
>
>




  • Prev by Date: Re: 1/Trig function - help
  • Next by Date: Divisors
  • Previous by thread: Re: Using Block instead of Module?
  • Next by thread: RE: Using Block instead of Module?