|
|
> As an example, take the simple case where I have two values A and B, and I
> need their sum and their product. Is there a way to do this with one
> macro?
You can return values by parameter, but shouldn't because it's bugged...
IE #macro Foo(A, B, result1, result2) is bad, but might be fixed someday.
So that leaves passing values by substitution, which perty much limits you
to returning one variable. However, there are types of variables that have
more than one value, most notably vectors. You can fit up to 4 floats in a
vector and later access them with the .x,.y,.z, and .t operators. Or you can
return an array that holds the results.
#macro sum_product(A,B)
#local mysum = A+B;
#local myproduct = A*B;
#local result = array[2]{mysum,myproduct};
result
#end
#declare sum_product_result = sum_product(2, 3);
#declare sum_result = sum_product_result[0];
#declare product_result = sum_product_result[1];
Post a reply to this message
|
|