AccessMyLibrary provides FREE access to millions of articles from top publications available through your library.
Create a link to this page
Copy and paste this link tag into your Web page or blog:
Cut development time and create compact, well-organized macro code.
Knowing how to fully exploit the subroutine facility in 1-2-3's macro language may be your most important tool for building efficient, elegant macros. Subroutines let you avoid writing the same code more than once. More important, they let you avoid "spaghetti code," the bewildering labyrinth that occurs when a program branches here, there, and somewhere else if a condition is met.
A subroutine is a segment of code that a program jumps to temporarily, after which it jumps back to the calling routine and proceeds to the next instruction. Subroutines drastically cut the size of a macro that repeatedly performs the same task or nearly the same task.
Unlike other languages you may have worked with, 1-2-3's macro language does not include a verb, such as GOSUB or CALL, that invokes a subroutine. Instead, you include a subroutine call in a macro by enclosing the name of the subroutine in braces. For example, to call a subroutine whose first cell is named setup, include the instruction {setup} in the macro. In this way, a subroutine call resembles a macro command, such as {PANELOFF}. You may include parameters in the braces along with the subroutine call. This results in an instruction that resembles a command with arguments, such as {GETLABEL prompt, target_cell}.
Though all subroutine calls work the same way, I've found it useful to think of them in terms of what you want them to do. …