|
|
Hmm, the problem seems to be as follows:
declares of floats need to be followed by ';'
#declare A=1;
1) placing the ';' outside an #if block doesn't work, the #else or #end is
encountered before the semicolon is found
#declare B= #if(A=1) 12 #else 13 #end; ---> doesn't work
2) placing the ';' inside an #if block does work
#declare B= #if(A=1) 12; #else 13; #end ---> works
essentially what is happening is event 1), the macro contents replace the
macro call, thus the semicolon gets placed outside the #if block and
generates an error. When placing this inside the str() or concat()
functions, the semicolon is not required insdie the function and it parses
fine.
In order to get it to work, you will either need to make you own macro or
modify the one in arrays.inc and remove the #if block (it's only there as
an error check so it isn't absolutely necessary):
#macro Rand_Array_Item(Array, Stream)
//remove #if(dimensions(Array)=1)
Array[floor(rand(Stream)*0.9999999*dimension_size(Array,1))]
//remove #else
//remove #error "The Rand_Array_Item() macro only works for 1D
arrays."
//remove #end
#end
becomes:
#macro Rand_Array_Item(Array, Stream)
Array[floor(rand(Stream)*0.9999999*dimension_size(Array,1))]
#end
Also: adding the semicolon to the macro isn't the best solution as then
functions like str() and concat() won't work with it
also, the macro could be rearranged to keep the error check as:
#macro Rand_Array_Item(Array, Stream)
#if(dimensions(Array)!=1)
#error "The Rand_Array_Item() macro only works for 1D arrays."
#end
Array[floor(rand(Stream)*0.9999999*dimension_size(Array,1))]
#end
-tgq
Post a reply to this message
|
|