!goto - Unconditional labeled jump
!tgoto - Conditional labeled jump
!tgoto condition label
Flow can be controlled within a MicroEmacs '06 macro using the !goto directive. It takes as an argument a label. A label consists of a line starting with an asterisk (*) and then an alphanumeric label. Only labels in the currently executing macro can be jumped to, trying to jump to a non-existing label terminates execution of a macro. labels may be located at any position within the macro (forwards or backwards from the !goto).
A conditional jump may be implemented with a !tgoto, this takes an additional argument condition, which may be a literal numeric value, a variable or an evaluated expression (see Variable Functions). If the condition evaluates to TRUE (or non-zero) then the branch is taken and control continues from the label.
For example, create a block of DATA statements for a BASIC program:
insert-string "1000 DATA " set-variable %linenum 1000 *nxtin screen-update ;make sure we see the changes set-variable %data @ml"Next number: " !if &equal %data 0 !goto finish !endif !if &greater $curcol 60 2 backward-delete-char newline set-variable %linenum &add %linenum 10 insert-string &cat %linenum " DATA " !endif insert-string &cat %data ", " !goto nxtin *finish 2 backward-delete-char newline
Not that any of us are writing basic programs these days !!
!goto and !tgoto are expensive operations because a symbolic name lookup is performed in the macro file. For time critical macros then the !jump(4) and !tjump(4) directives should be used as these do not perform a symbolic name search. The jump equivalents are source sensitive since a line displacement rather than a label is used - this makes them a little dangerous to use.
Copyright (c) 1998-2006 JASSPA
Last Modified: 2002/01/11
Generated On: 2006/10/07