Quick Links
AIML Tutorials
MakeAiml Tutorials
C Programming
Download
Advertisements
Template Creation With Macros Tutorial
Introduction
In this tutorial you will learn how to create complex pattern/template groups using Macros and loops in MakeAiml.
MakeAiml Macros
If you are familiar with the C programming language, you probably understand what a "macro" is, if you're not don't worry because the concept is very simple. A MakeAiml macro works exactly like C macro does in that it replaces the macro with predefined text. Here is an example:
! Remember...comments begin with the ! character
! The macro on the next line defines the bot's name
$ my_name Larry
p what is your name
t My name is $$my_name.
There are two lines you need to look at above, line 3 (begins with the dollar sign $) and the line that starts the template (begins with t). Line 3 tells MakeAiml to remember a macro called my_name which contains the text Larry. In order to "use" this macro, all a programmer needs to do is insert the name of the macro somewhere into the line of MakeAiml code prefixed with two dollar signs $$. When MakeAiml reads the line:
t My name is $$my_name.
It will see:
t My name is Larry.
All spacing around the macro is preserved, so don't be afraid to allow the name of the macro to run together with the surrounding text...like so:
$ i_am_a robot
p you are weird
t Please don't hold my $$i_am_aness against me :-(
MakeAiml will see the template line as:
t Please don't hold my robotness against me :-(
It might take a little thinking to get the macro expanded correctly, but you will understand how powerful of a tool this can be in the next section of the tutorial.
About the Author
Grant Dryden works as a computer engineer. He writes software in C and C++ for embedded systems as well as firmware in VHDL. He has a Bachelor of Science in Computer Engineering.

