break

This forum serves as MSCI Reference at EGOSOFT. It's Read-Only for non MSCI Group members.

Moderators: Scripting / Modding Moderators, MSCI Moderators

Locked
mark_a_condren
Posts: 1385
Joined: Wed, 3. Aug 05, 05:05
x3tc

break

Post by mark_a_condren » Fri, 10. Sep 10, 16:22

break


Breaks out of the current 'while' loop's code block and begins executing code after that loop's 'end' statement.


Example:

$loop = 5
while $loop > 0
| dec $loop =
| if $loop =< 2
| | break
| else
| | write to player logbook = $loop
| end
|@ = wait 100 ms
end
write to player logbook = 'loop ended'


This would result in 5, 4 and 3 being written to the players logbook but 1 and 2 would be missed as the 'if' condition passed, so the 'break' was used (it wouldn't even get to check 1 ). The next thing written would be 'loop ended'


Command Location:

Alex Vanderbilt
Winner X3 Sektorquest
Posts: 2120
Joined: Thu, 4. May 06, 12:07
x3tc

[TiP][49] 286641

Post by Alex Vanderbilt » Fri, 1. Oct 10, 14:35

break

Ein momentan laufender while-(während)-Codeblock wird abgebrochen und es wird mit dem nach dem 'end' folgendenen Code fortgefahren.

Beispiel:

$loop = 5
while $loop > 0
| dec $loop =
| if $loop =< 2
| | break
| else
| | write to player logbook = $loop
| end
|@ = wait 100 ms
end
write to player logbook = 'loop ended'

Hier würden 5; 4 und 3 in das Spielerlogbuch geschrieben, da sie größer als 2 sind. 1 und 2 jedoch würden ausgelassen weren, da die if-Bedinung erfüllt wurde, und breake vom Code angewendet wurde. 1 würde aufgrunddessen nicht einmal vom Code überprüft werden. Der nächste ins Log geschriebene Text wäre dann 'loop ended'.


Zu finden unter:

User avatar
Capux
Posts: 2141
Joined: Sat, 31. Oct 09, 22:17
x4

[39] 286641

Post by Capux » Thu, 21. Oct 10, 21:52

break


Esce immediatamente dal ciclo 'while' e riparte eseguendo il codice che si trova subito dopo il ciclo 'while'.


Esempio:

$loop = 5
while $loop > 0
| dec $loop =
| if $loop =< 2
| | break
| else
| | write to player logbook = $loop
| end
|@ = wait 100 ms
end
write to player logbook = 'loop ended '


Questo scriverà 5, 4 e 3 nel diario di bordo ma 1 e 2 verranno tralasciati perchè quando si attiva l'istruzione 'if', il 'break' viene usato e chiude il ciclo (non ricomincia nemmeno, non viene fatta una nuova verifica delle condizioni). La nuova scritta nel diario sarà 'loop ended'.


Posizione dell'istruzione nella lista:

Locked

Return to “MSCI Reference”