Jump to content
Developer Wiki and Function Reference Links Read more... ×
Sign in to follow this  
PeterT

Document List Handling

Recommended Posts

Hi Ray,

Thanks for sharing your considerable knowledge of Last and LastNew objects.

LObject in particulas has always been a bit of a mystery whenever I've tried it.

Very tricky indeed! You must've spent a bit of time testing those.

Share this post


Link to post

I ran the script, but VW didn't crash. But ProcessSym will only be activated once because symbols must have a unique name.

No, only symbol definitions must have a unique name but you can have as many symbol "instances" in the document which is what the criteria is looking for. It would prove my finding that the script cannot reallocate and will stop at the second iteration if you indeed tested it with several symbol "instances".

Share this post


Link to post

According to vScript Language guide you 'should' be able to re-allocate:

"Once all the objects have been processed, the array can be redimensioned to allocate more or less space as needed. In the example, additional storage space is reserved with another call to ALLOCATE,

.....

Note that the existing data values stored in the array are preserved when the array is re-dimensioned. If an array is redimensioned to a larger size during execution of the script, VectorScript will preserve all the values currently in the array. VectorScript will also attempt to preserve as many data values as possible if an array is redimensioned to a smaller size. In the case of dimensioning to a smaller size, any values contained in locations beyond the newly defined boundaries of the array will be lost."

But then, things don't always work like they're supposed to.

I'm curious as to why you'd want to repeatedly call allocate in a loop. Maybe it's because I'm more of a static guy, but my first inclination is to run a count as a separate routine and allocate once.

Strikes me a bit odd, so it seems like an opportunity to learn something.

Share this post


Link to post

So in an effort to learn something I went back to Language Guide and found:

"It is highly recommended that you use static arrays wherever possible for the best possible script performance. If dynamic arrays are required in your scripts, avoid making frequent calls to ALLOCATE to reserve storage. Use ALLOCATE only when absolutely necessary to change reserved storage during script execution, and avoid any use of ALLOCATE inside of a loop or repetition statement (see Repetition Statements for details on these statement types)."

It doesn't say it'll crash VW though. Of course...it's only a guide.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×