On Fri, 25 Sep 2009, Alan G Isaac wrote:

>
> >  On Fri, 25 Sep 2009, Alan G Isaac wrote:
> > > I would like to change working directory dynamically in
> > > a script, to the location of the script (*without* knowing
> > > where that is). Is there an easy way (for students)?
>
>
> On 9/25/2009 2:43 PM, Allin Cottrell wrote:
> >  Offhand, no. But what are you actually trying to do, in the larger
> >  scheme of things? There may be an easier way of doing it.
>
>
> Students store data relative to the scripts.
> E.g.,
>          coursefolder
>                  scripts
>                  data
>                  temp
>
> Now gretl will search for data relative to the
> script directory, so on Windows they can use
>
>          open ..\data\mydata.gdt
>
> But now suppose they try the obvious:
>
>          store ..\temp\tempdata.gdt
>
> This does not work, because store presumes
> this is all relative to the working directory.
> Students are often using lab computers with
> network drives or flash drives, so it works
> best if everything is relative to their
> scripts directory.
>
> Things are actually worse than this.  Suppose
> they try
>
>          store tempdata.gdt
>          open tempdata.gdt
>
> Now `store` will store this in the working directory,
> but `open` will first look relative to the script,
> so if there is also a `tempdata.gdt` in `classfolder`scripts`
> they will open that by mistake!
>
> Hope that's illustrative,

It is, thanks.  But wouldn't it be easier to have a structure of

coursefolder
   projects

where projects/foo would contain foo.inp, foo.gdt and any other
relevant material?  Then if you're working on project foo you just
set coursefolder/projects/foo as gretl's working directory and
you're not stumbling around in the dark.

A highly structured hierarchy such as you describe works fine if
you're running gretl from the command prompt in an xterm and have
the gretl working directory set to shadow the PWD, but on Windows
it seems like it's bound to make for an uphill struggle.

Allin


Reply via email to