• Hey! Guest! The 37th GMC Jam will take place between May 28th, 12:00 UTC and June 1st, 12:00 UTC. Why not join in! Click here to find out more!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Question - Code About Macros holding a simple operation

I've just scratch my head around a weird issue coming from macro and brackets to find out that it may not be weird at all, but I would like a confirmation.

Doing this :
Code:
#macro val 5/2

v = 10 / val
will return v = 1

but adding brackets to the division held in the macro :
Code:
#macro val (5 / 2)

v = 10 / val
will result v = 2

I guess that's the expected behavior as the documentation give the example of having a random blending color each time the macro is called :
Code:
#macro col make_colour_hsv(irandom(255), 255, 255)


But well, in order to be sure ...
 

TsukaYuriko

šŸŒ 
Forum Staff
Moderator
Macros are full-text search and replace. Any occurrence of the macro will be substituted with its value, and any evaluations will be done in place. If you want it to have the value of 5 / 2 (2.5), you have to put parentheses around it, as other operators may take precedence otherwise if you use it in a formula.
 
Top