!jump - Unconditional relative branch
!tjump - conditional relative branch
!jump offset
!tjump condition offset
Flow can be controlled within a MicroEmacs '99 macro using the !jump directive. It takes as a numerical argument offset. The offset is a signed relative displacement, it may be a literal numeric value, a variable or an evaluated expression (see Variable Functions). The displacement to jump starts from the current !jump line. (i.e. 0 goto) would loop forever as it jumps to itself). Negative offset branches backwards, positive offset forwards.
A conditional relative branch, with a numerical displacement is specified using !tjump. This has an additional argument condition which is evaluated and if TRUE (Non-zero) then the branch is taken. The condition may be a variable or an evaluated expression.
!jump and !tjump are fast equivalents of !goto(4) and !tgoto(4), respectively. !jump should be used with care as these calls are source sensitive and unexpected results may be obtained if the offset's are specified incorrectly.
Comments are not counted as valid lines within the relative displacement, these are stripped out when the macro is loaded. When using a relative branch ensure that ONLY the code lines are counted.
For some seriously dirty macro tricks then the !jump directive becomes very useful. The following example is taken from the Metris macro (which is packed with goodies if you can find time to work out what it does !!). The following example uses the random number generator $random(5) to generate a random number which scaled and used as a !jump offset, thereby creating a switch type statement.
0 define-macro met-select-piece !jump &mul 5 &add 1 &div &mod $random 71 10 set-variable :met-np1 " X " ; 1st 3 lines are dummies to get offset right set-variable :met-np1 " X " set-variable :met-np1 " X " set-variable :met-np1 " X " set-variable :met-np1 " X " set-variable :met-np2 "XX " set-variable :met-np3 " X " set-variable :met-ncol %lyellow !return set-variable :met-np1 "XX " set-variable :met-np2 "XX " set-variable :met-np3 " " set-variable :met-ncol %yellow !return set-variable :met-np1 "X " set-variable :met-np2 "XX " set-variable :met-np3 " X " set-variable :met-ncol %lmagenta !return set-variable :met-np1 " X" set-variable :met-np2 " XX" set-variable :met-np3 " X " set-variable :met-ncol %lgreen !return set-variable :met-np1 " X " set-variable :met-np2 " X " set-variable :met-np3 " XX" set-variable :met-ncol %magenta !return set-variable :met-np1 " X " set-variable :met-np2 " X " set-variable :met-np3 "XX " set-variable :met-ncol %green !return set-variable :met-np1 " X " set-variable :met-np2 " X " set-variable :met-np3 " X " set-variable :met-ncol %lblue !return set-variable :met-np1 " X " set-variable :met-np2 " X " set-variable :met-np3 "X X" set-variable :met-ncol %lred !emacro
(c) Copyright JASSPA 1999
Last Modified: 1999/08/24
Generated On: 1999/12/01