|
![](/i/fill.gif) |
Wasn't it Roland Vansteenkiste who wrote:
>On Tue, 28 Dec 1999 12:06:48 -0800, Jerry <jer### [at] acusd edu> wrote:
>
>>In article <386908a5.2657716@news.povray.org>,
>>rol### [at] ping be (Roland Vansteenkiste) wrote:
>>
>>>Tying to create a macro that use a array I've a problem.
>>>Having the following code
>>>
>>>#declare Numberofdigits = 10
>>>#declare digits = 1,20,10,4,5,3,87,8,21,4
>>>
>>>How can I put this variable number of digits into an array?
>>>
>>>Roland
>>>
>>
>>#declare myDigits = array[Numberofdigits] {
>> 1,20,10,4,5,3,87,8,21,4
>>}
>>
>>Jerry
>
>Thanks Jerry, but I knew that answer. The meaning is that Pov does the
>job and not me. How can I Pov make read the numbers and put them into
>the array
>
If you'll accept digits as a string, then you can extract values from
its substrings. As it stands, I don't know what the incorrect
#declare digits = 1,20,10,4,5,3,87,8,21,4
is intended to mean.
#declare Numberofdigits = 10;
#declare digits = "1,20,10,4,5,3,87,8,21,4"
#declare MyArray = array[Numberofdigits]
// It's much easier if there's an extra comma at the end
// so we don't have to check for running off the end of the string
#declare MyDigits = concat(digits,",")
#declare C = 1; // start of substring
#declare K = 1; // end of substring
#declare N = 0;
#declare Comma = asc(",");
#while (N < Numberofdigits)
#while (asc(substr(MyDigits,K,1)) > Comma)
#declare K=K+1;
#end
#declare MyArray[N] = val(substr(MyDigits,C,K-C));
#end
--
Mike Williams #
Gentleman of Leisure
Post a reply to this message
|
![](/i/fill.gif) |