[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Multiple input()
From: |
Paul Laub |
Subject: |
Re: Multiple input() |
Date: |
Thu, 18 Nov 2004 22:39:59 -0800 |
Dear Joe,
What about calling input() with the optional second argument of "s"?
That way, one item, a string, is returned. That string, however, could
contain multiple values separated by whitespaces or commas or
whatever. Then you could use Octave's strtok() to parse the individual
values from that string. By putting strtok() within a loop, you could
in principle parse out all of an unknown number of values in the
string. (At least that is how the same named strtok library function
in C is used.)
Paul Laub
On Thu, 18 Nov 2004 21:10:28 -0700, Joe Koski <address@hidden> wrote:
> To quote from the February 1997 GNU Octave Manual, p. 127: "Currently input
> [meaning the Octave input() function] only returns one value, regardless of
> the number of values produced by the the evaluation of the expression."
> Entering "help input" in Octave-2.1.57 gets the same wording.
>
> Have any changes/updates allowed prompting for the reading a specified
> number of values? Is there a "workaround" that uses scanf(template,"C"), or
> similar constructs, that allows the number of inputs to vary from run to
> run?
>
> For a simple data plot display, I would like to ask: "How many columns to
> plot?: 3". (That I can do.) Then I would enter a varying number of column ID
> numbers, e.g. 5,10,15. Or, better yet, just count three entries and produce
> the plots.
>
> Yes, I could do it with a loop with input() asking for one column ID number
> at a time.
>
> Any ideas? Tricks? Suggestions? Thanks.
>
> Joe
>
> -------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL.
>
> Octave's home on the web: http://www.octave.org
> How to fund new projects: http://www.octave.org/funding.html
> Subscription information: http://www.octave.org/archive.html
> -------------------------------------------------------------
>
>
--
Safe Harbor Disclaimer: "Elvis has left the building."
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------