[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: BREAK statement and octave 5
From: |
Alice |
Subject: |
Re: BREAK statement and octave 5 |
Date: |
Tue, 5 Mar 2019 18:52:57 +0100 |
Many thanks for your kind and clear explanation of what was happening.
Marco
> Il giorno 5 mar 2019, alle ore 18:45, Mike Miller <address@hidden> ha scritto:
>
> On Tue, Mar 05, 2019 at 17:24:55 +0100, Alice wrote:
>> If I run the following code in Octave 4.x (on Mac) it works while in Octave
>> 5.x it doesn’t.
>> I know that the break statement should work only for loops but until ref 5.0
>> it worked also for the if statements.
>> I’m not able to find this change in the release notes. Is there anyone who
>> knows something more?
>> THNX
>> Marco
>>
>>
>> %% Input
>> A=input('A=? ') %1e-8;
>> B=input('B=?') %2;
>> C=input('C=?') %1e-8;
>>
>> %% A==0
>> if A==0
>> 'Error: 1'
>> break
>> end
>>
>> %% Delta
>> Delta=B^2-4*A*C;
>
> You're partially right, this code used to work in Octave 4.2, but not in
> Octave 4.4. The break statement should only be used inside of a loop.
>
> You may way to use something like this
>
> if (A == 0)
> disp ('Error: 1')
> return
> endif
>
> or this
>
> if (A == 0)
> error ('Error: 1')
> endif
>
> --
> mike