[Scilab-users] linking (jumping) from line of code to an other
Pierre Payen
payen.pierre at gmail.com
Tue May 16 15:18:52 CEST 2017
Is there some routines like goto ? I've never heard of it, so I doubt it.
The jumping (which can be partially achieved with break, abort, continue)
has to be avoided , with the reason explained in the previous emails.
Regarding your code, if we follow the algorithm then no matter DM, if P <
100 then you set up DM to 0 and increase P.
So you could switch the if statement , making the P test in the first place,
thus you only write your decreasing of P only once, as asked :
P = 200;
DM = 1;
for n = 1:10
if P > 100 then
if DM == 1 then
P = P - 60
else
P = P - 30
end
DM = 1
printf('P bigger than 100. DM = %d\n',DM)
else
DM = 0
P = P + 100 //instead of writing P = P + 100, I would like ...
printf('P smaller than 100. DM = %d\n',DM)
end
printf('%d %d\n',n,P) // changed disp for printf
end
--
View this message in context: http://mailinglists.scilab.org/Scilab-users-linking-jumping-from-line-of-code-to-an-other-tp4036375p4036403.html
Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.
More information about the users
mailing list