Quantcast

Re: linking (jumping) from line of code to an other

classic Classic list List threaded Threaded
1 message Options
Frieder Nikolaisen Frieder Nikolaisen
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: linking (jumping) from line of code to an other

The Solution is: Using whil:

i = 1
a = 1
 while i < 5 disp(i) a = a + 1 i = i +1 if a == 3 then i = i - 1 end end

 

Am 2017-05-12 11:15, schrieb Frieder Nikolaisen:

Hello,

another question to solve the locomotive stuff, giving you a example with the not implented code. 

I don't want to code the same stuff twice. Thats why I want to jump between lines of code. Is this possible and how? 

P = 200;
DM = 1;

for n = 1:10
    if DM == 1 then 
        if P > 100 then     DM = 1
                            P = P - 60
                            disp('P bigger 100. DM = ' + string(DM))
        else    DM = 0
                            P = P + 100 //instead of writing P = P + 100, I would like ...
                            disp('P smaller 100. DM = ' + string(DM))
        end 
    else // D == 0 
        if P > 100 then DM = 1          
                                        disp('P bigger 100. DM = ' + string(DM))
                        P = P - 30
        else        DM = 0              // ... to continue here 
                                        disp('P smaller 100. DM = ' + string(DM))
                    P = P + 100       // to use this P = P + 100
        end
    end 
    disp(string(n) + ' ' + string(P))
end
 

 

 

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Loading...