POV-Ray : Newsgroups : povray.advanced-users : Implementation of dynamically resized array Server Time
21 Dec 2024 21:50:23 EST (-0500)
  Implementation of dynamically resized array (Message 1 to 8 of 8)  
From: Bald Eagle
Subject: Implementation of dynamically resized array
Date: 2 Nov 2018 18:45:01
Message: <web.5bdcd2b755af31a9765e06870@news.povray.org>
Hi all,

I was restructuring some code, and wanted to take advantage of using the new
array features.

#local ToothPrismArray = array [1];

#local ToothPrismArray [0] = <_RC, _RC>;
#local ToothPrismArray [1] = RotatePoint (<_RC, 0>, -_HT);
#local ToothPrismArray [2] = RotatePoint (<_RB, 0>, -_HT);

When I get to the second line of element definitions, I get the old "Array
subscript out of range" error.

Is there a trick to this?

Am I a (few) version(s) behind?
(Windows)
version 3.8.0-alpha.9606898.blahblahblah


Thanks


Post a reply to this message

From: jr
Subject: Re: Implementation of dynamically resized array
Date: 2 Nov 2018 19:10:00
Message: <web.5bdcd8293ab1e8e96427f7f90@news.povray.org>
hi,

"Bald Eagle" <cre### [at] netscapenet> wrote:
> I was restructuring some code, and wanted to take advantage of using the new
> array features.
>
> #local ToothPrismArray = array [1];
>
> #local ToothPrismArray [0] = <_RC, _RC>;
> #local ToothPrismArray [1] = RotatePoint (<_RC, 0>, -_HT);
> #local ToothPrismArray [2] = RotatePoint (<_RB, 0>, -_HT);
>
> When I get to the second line of element definitions, I get the old "Array
> subscript out of range" error.
>


should work if you get rid of the initial dimension, ie

#local ToothPrismArray = array;


regards, jr.


Post a reply to this message

From: Bald Eagle
Subject: Re: Implementation of dynamically resized array
Date: 2 Nov 2018 19:30:01
Message: <web.5bdcdd0f3ab1e8e9765e06870@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:

> should work if you get rid of the initial dimension, ie
>
> #local ToothPrismArray = array;


I commented that out, and now

#local ToothPrismArray [0] = <_RC, _RC>;

gives me "Expected '=', [ found instead.

Is there a simple, easy link to download just the latest 64-bit executable file?


Post a reply to this message

From: Bald Eagle
Subject: Re: Implementation of dynamically resized array
Date: 2 Nov 2018 20:00:01
Message: <web.5bdce4ac3ab1e8e9765e06870@news.povray.org>
Just went to:
https://github.com/POV-Ray/povray/releases

Downloaded
Development build v3.8.0-alpha.9893777+av622

un7-zipped the file, renamed the old exe, copied over the new, ran it, checked
the version number in "about", and still have the same problem(s)trying to
render the scene.

So, It's not the version - I'm doing something wrong.

I even tried
#ifndef (ToothPrismArray [1]) #end

right before that, and got an error even trying to check if that array element
was defined.   :(


Post a reply to this message

From: Bald Eagle
Subject: Re: Implementation of dynamically resized array
Date: 2 Nov 2018 20:20:00
Message: <web.5bdce8a03ab1e8e9765e06870@news.povray.org>
http://news.povray.org/povray.general/message/%3C5b540d5e%241%40news.povray.org%3E/#%3C5b540d5e%241%40news.povray.org%3
E


#declare Foo = array;

This will create a resizable array with an initial size of zero, and
then grow the array...


So, it seems that ANY array is not resizable, only specially created arrays.


Post a reply to this message

From: clipka
Subject: Re: Implementation of dynamically resized array
Date: 3 Nov 2018 09:17:38
Message: <5bdd9ff2$1@news.povray.org>
Am 02.11.2018 um 23:41 schrieb Bald Eagle:
> Hi all,
> 
> I was restructuring some code, and wanted to take advantage of using the new
> array features.
> 
> #local ToothPrismArray = array [1];
> 
> #local ToothPrismArray [0] = <_RC, _RC>;
> #local ToothPrismArray [1] = RotatePoint (<_RC, 0>, -_HT);
> #local ToothPrismArray [2] = RotatePoint (<_RB, 0>, -_HT);
> 
> When I get to the second line of element definitions, I get the old "Array
> subscript out of range" error.
> 
> Is there a trick to this?

Yes. The normal arrays are still fixed; you need to declare the array 
differently:

     #local ToothProsmArray = array;

Note the absence of any dimensions. This declares a one-dimensional 
variable-sized array.

Before anyone asks, multi-dimensional variable-sized arrays are not 
supported.


Post a reply to this message

From: clipka
Subject: Re: Implementation of dynamically resized array
Date: 3 Nov 2018 09:30:59
Message: <5bdda313$1@news.povray.org>
Am 03.11.2018 um 00:26 schrieb Bald Eagle:
> "jr" <cre### [at] gmailcom> wrote:
> 
>> should work if you get rid of the initial dimension, ie
>>
>> #local ToothPrismArray = array;
> 
> 
> I commented that out, and now
> 
> #local ToothPrismArray [0] = <_RC, _RC>;
> 
> gives me "Expected '=', [ found instead.

Make sure you have NOT un-commented the semicolon.

Without the semicolon, POV-Ray will continue scanning for an opening 
square bracket. The next `#local` is /not/ sufficient for POV-Ray to 
recognize that you're done declaring the array; instead, POV-Ray will 
just postpone parsing the array declaration, expecting it to be 
continued after the second `#local`. So you'll end up with an attempt to 
assign an array element before the array even exists, and POV-Ray gets 
all confused.


Post a reply to this message

From: clipka
Subject: Re: Implementation of dynamically resized array
Date: 3 Nov 2018 09:32:16
Message: <5bdda360$1@news.povray.org>
Am 03.11.2018 um 14:31 schrieb clipka:

> Make sure you have NOT un-commented the semicolon.

I meant to write "NOT commented out" of course.


Post a reply to this message

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