- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 09-21-2018 12:49 PM
(1124 views)
why couldnt i have just done age=13 instead of age=&age? what is the purpose of macro variables?
4 REPLIES 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
In this trivial example, the macro variable does nothing that you couldn't do better without the macro variable.
In other examples, macro variables allow code to be dynamic, and change as needed without the human programmer having to re-write or re-code large portions of text.
--
Paige Miller
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@clqa wrote:
why couldnt i have just done age=13 instead of age=&age? what is the purpose of macro variables?
The purpose of macro variables is character substitution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Think about a bigger program where you have to reference age in lots of places. In this example, it references age in 2 spots. Using a macro variable instead means if you need to change the age, you only need to do it in one location. It also prevents you from accidentally not updating the age in one of the locations in your code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
There is always more than one way to do something.
What happens when you want to do it for each age in the data?
@clqa wrote:
why couldnt i have just done age=13 instead of age=&age? what is the purpose of macro variables?