octave-maintainers
[Top][All Lists]
Advanced

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

Re: Error with test script


From: Rik
Subject: Re: Error with test script
Date: Sat, 30 Aug 2014 20:46:18 -0700

On 08/30/2014 08:06 PM, Daniel J Sebald wrote:
> On 08/30/2014 09:55 PM, Tatsuro MATSUOKA wrote:
>>
>>
>>
>>
>> ----- Original Message -----
>>> From: Rik<address@hidden>
>>> To:
>>> Cc: address@hidden
>>> Date: 2014/8/31, Sun 11:23
>>> Subject: Re: Error with test script
>>>
>>>
>>> On 08/29/2014 11:58 PM, address@hidden wrote:
>>>
>>> Subject:  Octave becoming too MATLAB compatible ?
>>>> From:  Ulf Griesmann<address@hidden>
>>>> Date:  08/29/2014 01:21 PM
>>>> To:  address@hidden
>>>> List-Post:<mailto:address@hidden>
>>>> Content-Transfer-Encoding:  8bit
>>>> Precedence:  list
>>>> MIME-Version:  1.0
>>>> Message-ID:<address@hidden>
>>>> Content-Type:  text/html; charset=utf-8
>>>> Message:  2
>>>>
>>>>
>>>> I am sure the following script used to work in Octave:
>>>>
>>>> -----------------------
>>>> # test script
>>>> say_hello;
>>>>
>>>> function say_hello
>>>>      fprintf('Hello !\n');
>>>> endfunction
>>>> -------------------------
>>>>
>>>> Now I get the following error in both 3.8.2 and the development
>>          version:
>>>>
>>>> octave:1>  testscript
>>>> error: 'say_hello' undefined near line 5 column 1
>>>> error: called from:
>>>> error:   /home/ulfg/Octave/testscript.m at line 5, column 1
>>>> octave:1>
>>>>
>>>> I don't know if this is a bug or intentional.
>>> I don't think this was ever legal in Octave.  I just tested with
>>      versions 3.2.4, 3.4.3, 3.6.4, 3.8.0 and they all give the same error
>>      as with 3.8.2.
>>>
>>> --Rik
>>
>>
>> Octave manual
>> http://www.gnu.org/software/octave/doc/interpreter/Script-Files.html#Script-Files
>>
>>
>> clearly says that a script file with function for example
>> may be written as:
>>
>>
>> # Prevent Octave from thinking that this
>> # is a function file:
>>
>> 1;
>>
>> # Define function one:
>>
>> function one ()
>>    …
>>
>> Tatsuro
>
> Yes, but that does currently work.  The test script in this case is
> defining global functions because the contents of the file are being
> treated as command-line script statements.  Hence, following the
> execution of those scripts the functions will be resident in Octave (not
> local to some function file).  I.e.,
>
> -----------
> # test script
>
> 1;
>
> function say_hello
>     fprintf('Hello !\n');
> endfunction
> -----------
>
> octave-cli:10> testscript
> octave-cli:11> say_hello
> Hello !
>

This example is completely valid.  There is no attempt to call a function
that has not been defined yet.  The example in the manual represents a good
way of defining multiple functions in a single m-file without provoking the
file name does not agree with function name warning.

--Rik



reply via email to

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