help-octave
[Top][All Lists]
Advanced

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

Re: Command line parameters


From: Daryl Lee
Subject: Re: Command line parameters
Date: Tue, 26 Apr 2011 12:45:42 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.15) Gecko/20110303 Lightning/1.0b2 Thunderbird/3.1.9

On 4/26/2011 11:36 AM, Martin Helm wrote:
Am Dienstag, 26. April 2011, 19:20:58 schrieb Daryl Lee:
I'm fairly new to Octave.  I've figured out how to pass command-line
arguments to a script, but only if that script is an executable script or
called from the system command line, a la "$ octave myscript.m arg1 arg2".
Is there a way to do so from the Octave console?  When I am at the Octave
prompt and type "myscript arg1 arg2" I get "error: invalid use of script in
index expression."  I'm using Octave 3.2.4 on a Windows 7 64-bit laptop.

Here is the script that I have so far:
====================
% Display command line

printf('%s; %d arguments\n', program_name(), nargin);
arg_list = argv();
for i = 1:nargin
     printf('%d argument = %s\n', i, arg_list{i});
endfor

printf('\n');
====================

I am really not sure if I understood what you want. But what about
system("octave myscript.m a b")

at the octave command prompt?



Well, that works, but the value of arg_list (or any other variable, I'm guessing) isn't available to me after the script terminates. It seems to me (again, perhaps naively) that one primary reason for using the console in the first place is to be to be able to go in after a script runs and examine the values as a debugging step.

--
Daryl Lee



reply via email to

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