Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

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

Search the Archive

Re: Reading a module library from plain text file

  • To: mathgroup at smc.vnet.net
  • Subject: [mg90091] Re: [mg90056] Reading a module library from plain text file
  • From: Oliver Ruebenkoenig <ruebenko at wolfram.com>
  • Date: Sat, 28 Jun 2008 05:54:20 -0400 (EDT)
  • References: <200806271018.GAA24277@smc.vnet.net>

Dear Carlos,

carlos at Colorado.EDU wrote:
> Question: is it possible to read a set of modules into a Notebook cell without
> using the Package format?
>   
try,

ToExpression[ Import["test.txt"] ]

> More specifically, I have a set of modules (600 or so, total of about 40000 lines)
>  for a particular program to be used for assigned homework this fall.
>  To reduce the volume of the distributed notebook I was thinking of
> placing the needed
>   
Why do you not use gzip or bzip.... ? You also could save the packages 
as a *.m file and distribute that - possiblz compressed.

> modules into a *plain text*  library file,  say HomeworkModLib.txt,
> and read it in the
> C++ fashion from an initialization cell of the actual assignment NB:
>
> -----------------------------------------
>   <<"HomeworkModLib.txt";    (* Initialization input cell has only
> this command *)
> -----------------------------------------
>   Homework script in another input cell  - prepared by student
> -----------------------------------------
>
> If this is possible, here are subquestions:
>
> 1.  Must the ModLib file  have a special extension?  my OS is Mac OSX
> 10.4.11 but
>      students could be using Windows, Linux or other Unix flavors
>   
Import as text should be fine.
> 2.  Must the file be in the same directory as the NB for platform
> independence?
>   
I do not understant the question. You might want to look at
$Path,  ResetDirectory,  ParentDirectory,  DirectoryStack, 
$HomeDirectory, DirectoryName, FileNames
Also, you can give
ToExpression[ Import["/path/to/my/test.txt"] ]
> 3.  Will execution of the cell initialize the modules and make them
> available
>     to the homework script?
>
> Constraints: this must work on versions >=4.1
>   

How much do you expect to save by using this method?

Oliver



  • Prev by Date: Re: Modulus / Absolute Value
  • Next by Date: Re: Re: Problem with NMaximize
  • Previous by thread: Reading a module library from plain text file
  • Next by thread: Mathematica => PDF => Illustrator problem solved! (Sort of...)