Your browser (Internet Explorer 8 or lower) is out of date. It has known security flaws and may not display all features of this and other websites. Learn how to update your browser.

X

Menu

Macros

Macros allow you to define custom model code that is included in the model.

For instance, you could use macros to define a custom function that is accessible in all the equations in your model. For example, imagine you had a model where you needed to calculate the sine of the division of the sum and product of three numbers in many different places. Now you could write this equation out wherever it occurred. However, that might be tedious and prone to error. Additionally, if you later decided you had to use the the cosine instead of sine, there would be many different parts of your model you would need to update.

By defining macros for models we can create a function to carry out this repetitive task. Insight Maker can define single-line functions like so:

myFn(a, b, c) <- sin((a+b+c)/(a*b*c))

Multiline function can be defined using this syntax:

Function myFn(a, b, c) x <- (a+b+c) y <- (a*b*c) return sin(x/y) End Function

Macros can also be used to define variables that will be available in the model such as a counter. Another use of macros is to set the random seed for the model so the same set of random numbers will be generated each model run:

setRandSeed(99)

See the Advanced Equations section of this manual for more information on the syntactical constructs you can use in your macros.