help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Passing arguments to a script.


From: Richard KIrk
Subject: Passing arguments to a script.
Date: Mon, 8 Jul 2013 07:07:08 -0700 (PDT)

Hi.

I was wanting to load a lot of test data using a script. I had one .m file
for each set of data. In these scripts, the 'load' command would read a lot
of parameters from a file, and then we had some housekeeping operations to
make sure the data was all consistent in the current scope. I wanted to make
a single .m file that worked like this...

> loadTestData <name>

You can't do this with a script. If you call a script with arguments, you
get an error. This means there is no cunning way of getting the last command
line from the history or anything. But you can do what you want with a
function.

You can write a function, but then all the values you read in with the
'load' call are in the local scope, and are lost when your function
completes. What you want is some way of importing values from the calling
scope, and exporting values back again, without going through the regular
function argument passing process.

It can be done. The functions you are looking for are...
  assingnin('caller', name, value); % this sets the value in the calling
shell
  evalin('caller', try, catch); % this evaluates the expression in the
calling shell


 .



--
View this message in context: 
http://octave.1599824.n4.nabble.com/Passing-arguments-to-a-script-tp4655329.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]