EnglishGermanFrenchRussianPolishItalianSpanish
Log inRegister
 
gosub <Label>
Post new topic This topic is locked: you cannot edit posts or make replies.
View previous topic :: View next topic
Author Message
mark_a_condren





Joined: 03 Aug 2005
Posts: 1384 on topic
Location: Newcastle - Australia
Thank you for registering your game
PostPosted: Fri, 10. Sep 10, 17:00    Post subject: gosub <Label> Reply with quote Print

gosub <Label>


<Label> = A predefined 'label' in your script.


Allows you to define the name and location of a <Label> that is used as the jump destination for a gosub statement.
When a gosub statement is encounted the script will jump to the location of the <Label> and continue on until the first endsub is reached and then return to the position directly under the gosub statement.

The 'sub' part of the name implies a downward direction, however, 'gosub' intructions can be jumps in an upwards direction in your script.

Example:

write to player logbook = 1
write to player logbook = 2

gosub mix.numbers
write to player logbook = 3
write to player logbook = 4

return null

mix.numbers:
write to player logbook = 5
endsub


In this case the numbers would be written to the logbook in the following order, 1, 2, 5, 3 and 4 due to the 'gosub' causing 3 and 4 to be put after 5. (5 would not be written twice due to the 'return null' being encountered)


Command Location:



Back to top
View user's profile Send private message Send e-mail
Alex Vanderbilt
Winner X3 Sektorquest


MEDALMEDAL

Joined: 04 May 2006
Posts: 2111 on topic

Thank you for registering your game
PostPosted: Sat, 2. Oct 10, 18:04    Post subject: [TiP][49] 286646 Reply with quote Print

gosub <Label>

<Label> = Eine vordefinierte Bezeichnung oder Markierung in einem Skript.

Dieses Kommando erlaubt es, eine Bezeichnung/Markierung oder Stellenangabe eines <Label>, die als Sprungziel einer gosub-Aussage dient. Sobald eine gosub-Aussage im Kode entdeckt wird, springt das Skript zu dem im <Label> angegebenen Punkt und setzt da die Verarbeitung des Kodes fort bis ein "endsub" gefunden wird. Nach dem "endsub" kehrt das Skript zu der Kodezeile zurück, der direkt auf die gosub-Aussage folgt.

Der "sub"-Teil im Namen impliziert eine nach unten gerichtete Bewegung. Allerdings könnten gosub-Anweisungen auch nach oben im Skript springen.

Beispiel:

write to player logbook = 1
write to player logbook = 2

gosub mix.numbers write to player logbook = 3
write to player logbook = 4

return null

mix.numbers:
write to player logbook = 5
endsub

In diesem Fall würden die wie folgt in das Logbuch geschrieben: 1; 2; 5; 3 und 4, da aufgrund der gosub-Anweisung von 2 zu 5 gesprungen wird, und das Skript nach dem endsub wieder zu 3 und 4 zurückkehrt. Das "return null" verhindert, dass 5 doppelt in das Logbuch geschrieben wird.


Zu finden unter:



Back to top
View user's profile Send private message
Juggernaut93



MEDAL

Joined: 17 Jul 2011
Posts: 1787 on topic
Location: Battipaglia (SA)
Thank you for registering your game
PostPosted: Tue, 22. May 12, 00:02    Post subject: [39]286646 Reply with quote Print

gosub <Label>


<Label> = Una 'label' predefinita nel tuo script.


Ti permette di definire il nome e la posizione di una <Label> che è usata come destinazione di salto per un'istruzione gosub.
Quando incontra un'istruzione gosub lo script salta alla posizione della <Label>, continua finché non raggiunge il primo endsub e poi ritorna alla posizione immediatamente sotto all'istruzione gosub.

La parte 'sub' del nome implica un salto verso il basso, comunque, però, le istruzioni 'gosub' possono saltare anche verso l'alto nel tuo script.

Esempio:

write to player logbook = 1
write to player logbook = 2

gosub mix.numbers
write to player logbook = 3
write to player logbook = 4

return null

mix.numbers:
write to player logbook = 5
endsub


In questo caso i numeri verrebbero scritti nel diario di bordo nell'ordine 1, 2, 5, 3, e 4 a causa del 'gosub' che fa in modo che il 3 e il 4 siano messi dopo il 5. (Il 5 non verrebbe scritto due volte perché si incontra l'istruzione 'return null')


Posizione dell'istruzione nella lista:



Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic This topic is locked: you cannot edit posts or make replies.
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum
Control Panel
Login Data
The time now is Wed, 3. Sep 14, 09:01

All times are GMT + 2 Hours


Board Security

Copyright © EGOSOFT 1989-2009
Powered by phpBB © 2001, 2005 phpBB Group
Template created by Avatar & BurnIt!
Debug: page generation = 0.18172 seconds, sql queries = 26