help-octave
[Top][All Lists]
Advanced

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

Re: Scripts within functions


From: Carnë Draug
Subject: Re: Scripts within functions
Date: Mon, 10 Oct 2011 15:33:39 +0100

On 10 October 2011 15:26, James Sherman Jr. <address@hidden> wrote:
> On Mon, Oct 10, 2011 at 9:45 AM, José Vallet <address@hidden> wrote:
>> I'd like to move some blocks of code (scripts) to the end of the file and
>> then call the scripts in different parts of the function. The purpose is
>> simply for cleanness of the code.
>
> I know (and this may be stating the obvious), but you can certainly call
> scripts within functions.  You could move the code you want in your script
> to another file to make a script, and then call it from your function.

Because the working directory does not change, the following will help
you in getting the path for your script files:

here   = which (name of the function from which you have the relative
path to script);
here   = fileparts (here);
script = fullfile (here, 'path to script relative to function file');
source ('script');

Carnë


reply via email to

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