[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: What's the correct order of things in a file? (beginner's question)
From: |
Bill Denney |
Subject: |
Re: What's the correct order of things in a file? (beginner's question) |
Date: |
Mon, 13 Jun 2005 20:46:54 -0400 (EDT) |
I'm changing the order of your questions a bit to avoid being
repetitive...
On Mon, 13 Jun 2005, David Collett wrote:
3. Finally, why does Wikipedia refer to their 7 blocks as "scripts"?
Why not just have all of these lines in a single file, as I have done?
They can be in the same or different files. If you put them into the same
file, then when you run one part of it, you run all of it, and there are
many cases where you would only want to run parts individually.
They call it a script because it is a set of commands to run as opposed to
a function which will (generally) return a value. Scripts generally run
functions (which, in octave, are most often separate files). Think of a
script as just saving you some typing while a function is something that
you'd call.
1. Why did the order I have work, but the one that Wikipedia gave
wouldn't? In other words, why does the function have to be moved up?
The function population was not defined. It wasn't defined because octave
didn't see its definition (the function population line) until after you
tried to call it.
2. In the Wikipedia version, they use for...end, and function...end,
whereas in the Octave manual, I believe it says to use: for...endfor,
and function...endfunction (which I did).
Can you use either? Are there different "flavors" of Octave that use
different commands?
I believe that endfor, endfunction, are older variants. They're still
valid, but you can just use end for all types of end (that I know of) now.
Bill
--
A professor is one who talks in someone else's sleep. -- unknown
-------------------------------------------------------------
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
-------------------------------------------------------------