Jump to content
Developer Wiki and Function Reference Links ×

Document List Handling


PeterT

Recommended Posts

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".

Link to comment

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.

Link to comment

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.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...