Jump: Difference between revisions

From EDukeWiki
Jump to navigation Jump to search
XTHX2 (talk | contribs)
No edit summary
No edit summary
Line 1: Line 1:
jump <addr>
'''jump''' <address>


<addr> - is a gamevar obtained by [[getcurraddress]]
<address> - is a gamevar that stores the destination address.


This command is also know as GOTO(http://en.wikipedia.org/wiki/Goto). Too bad this jump command isn't as good as it can be. It hardly can be used to jump forward because <addr> isn't known.
Transfers control to another statement with a specified <address> which should be obtained by the [[getcurraddress]] command. The address must be obtained before the corresponding jump command. This limitation makes it hardly possible to do a jump forward.


Here is an example. It countdowns the i variable from 10 to 0.
Here is an example that shows how to make a countdown loop(from 10 to 1) by means of the jump command.
   // addr and i are gamevars.
   // addr and i are gamevars.
   setvar i 10
   setvar i 10
Line 12: Line 12:
   addlogvar i
   addlogvar i
   subvar i 1
   subvar i 1
   ifvarn i 0 jump addr // if i isn't 0, jump to addr
   ifvarn i 0 jump addr // if 'i' isn't 0, jumps to addr


Yes, it could be done via [[whilevarn]] but it's just an example.


[[Category:EDuke32 specific commands]]
[[Category:EDuke32 specific commands]]

Revision as of 15:24, 31 July 2008

jump <address>

<address> - is a gamevar that stores the destination address.

Transfers control to another statement with a specified <address> which should be obtained by the getcurraddress command. The address must be obtained before the corresponding jump command. This limitation makes it hardly possible to do a jump forward.

Here is an example that shows how to make a countdown loop(from 10 to 1) by means of the jump command.

 // addr and i are gamevars.
 setvar i 10
 getcurraddress addr
 // begin loop
 addlogvar i
 subvar i 1
 ifvarn i 0 jump addr // if 'i' isn't 0, jumps to addr