POV-Ray : Newsgroups : povray.advanced-users : array-macro : Re: array-macro Server Time
30 Jul 2024 06:23:32 EDT (-0400)
  Re: array-macro  
From: Roland Vansteenkiste
Date: 31 Dec 1999 01:16:35
Message: <386c4ae1.1270526@news.povray.org>
On Wed, 29 Dec 1999 07:33:37 +0000, Mike Williams <mik### [at] nospamplease>
wrote:

>Wasn't it Roland Vansteenkiste who wrote:
>>On Tue, 28 Dec 1999 12:06:48 -0800, Jerry <jer### [at] acusdedu> wrote:
>>
>>>In article <386908a5.2657716@news.povray.org>, 
>>>rol### [at] pingbe (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   
>
Thanks Mike. Thats what I was looking for
Roland


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.