POV-Ray : Newsgroups : povray.advanced-users : array-macro Server Time
26 Nov 2024 15:14:10 EST (-0500)
  array-macro (Message 1 to 7 of 7)  
From: Roland Vansteenkiste
Subject: array-macro
Date: 28 Dec 1999 14:11:26
Message: <386908a5.2657716@news.povray.org>
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


Post a reply to this message

From: Jerry
Subject: Re: array-macro
Date: 28 Dec 1999 15:06:50
Message: <jerry-38E2F4.12064828121999@news.povray.org>
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


Post a reply to this message

From: Roland Vansteenkiste
Subject: Re: array-macro
Date: 29 Dec 1999 00:30:25
Message: <38699c88.1090748@news.povray.org>
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


Post a reply to this message

From: Nieminen Juha
Subject: Re: array-macro
Date: 29 Dec 1999 05:29:28
Message: <3869e288@news.povray.org>
Roland Vansteenkiste <rol### [at] pingbe> wrote:
: How can I Pov make read the numbers

  From where?

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Mike Williams
Subject: Re: array-macro
Date: 29 Dec 1999 13:04:30
Message: <ZQsRLCARlba4EwbF@econym.demon.co.uk>
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   








-- 
Mike Williams #
Gentleman of Leisure


Post a reply to this message

From: Matt Giwer
Subject: Re: array-macro
Date: 30 Dec 1999 01:29:49
Message: <386B25FF.F3A0ECC7@ij.net>
Roland Vansteenkiste wrote:

> 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

    external file I guess. Haven't looked into it. A looping readlin (or
comma recognizing routine) with an onerror flagging no more numbers. I
presume there is an onerror flag. (If not, make it a suggestion.)


Post a reply to this message

From: Roland Vansteenkiste
Subject: Re: array-macro
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.