Macros

Home • Gallery • Tutorials • Download • Purchase • Site Map
 

Inline Functions
Inline Methods
#Define Statements

Program Macros Overview

Macros are the set of Objects, Inline Functions, Inline Methods, and #Define Statements, available to all your Fractal Science Kit fractal programs. At first, you may not need any macros other than the built-in macros. In fact, it is recommended that you read through the built-in macros so you know what is available, and to get an idea how to define your own macros when the time comes. As you begin to develop fractal programs, you will find that you want to use a piece of code you have already written in another program. Creating a function or method in My Macros solves this problem. All the macros in My Macros can be used in any of your programs. Since the functions/methods are compiled inline and highly optimized, there is virtually no overhead for calling a macro.

Macros increase your productivity by allowing you to define blocks of code in a central location and include that code in your program simply by referencing the macro name. Macros can define arguments that allow you to pass information to the macro code when you call the macro.

Before you can use a macro, it must be defined. Macros are defined in 3 places:

  • Built-in Macros - This is the set of predefined macros. You cannot add or change these macros. These macros are used by many of the built-in sets of instructions. You should familiarize yourself with these macros so you can use them in your programs too.

  • My Macros - This is where you should place the macros that you develop. Macros added to this set are available to all your programs. After you add each macro, you should recompile My Macros to check for errors before you try to use your new macro.

  • macros section - Each program you write may include a macros section. Here you can place macros useful only to that program. Macros in the macros section, are different than macros you include in My Macros, because macros in the macros section have access to the program options defined in the properties section. This can be very useful but it does have the disadvantage that macros that work in My Macros may not work if copied into a macros section or vice versa. For example, if a macro from My Macros is copied into the macros section and has local variables with the same name as options defined in the program's properties section, errors will result.

Use the Macro Editor to view/edit the macro code in the built-in macros, My Macros, or any file containing macro definitions.

Warning

When you use a macro in a fractal program, the macro is expanded inline in your program when the program is compiled/run. This means that changes to the set of macros can impact existing programs and saved fractal properties files. This is both a blessing and a curse! If you improve a macro, all the programs and fractal files that reference the macro, will get the new and improved version the next time they are compiled. No action on your part is required. However, if you introduce a bug in a macro, or you change the required arguments to a macro, or you remove a macro altogether, you can break existing programs and fractal files without even knowing you have done so. You could even inadvertently change your favorite fractal by fixing a bug in a macro! Please be careful.

 

Copyright © 2004-2017 Hilbert, LLC
All rights reserved