How to test of a variable is a vector?

How do I test if a variable is a vector? Using typeof only tells me if it is an object.

I'm not sure there is a way, beyond assuming that if it's an object it's a vector (which may be enough, depending on where it has come from).

What's the context that you're needing to do the check in?

Check this:

The question arose from a bug in a half-written script. I created a vector, then created a vector as one of its entries. But because of my mistake, the entry was an empty string instead of a vector.

Then I saved the whole vector as a persistent variable, then retrieved it when I ran the script again, and the script crashed because I was treating the element as a vector.

So I thought, wouldn't it be a good idea to check first if the relevant entry was a vector!

Your replies have made it clear that fixing the bug (which I've now done) is much easier than trying to test whether the relevant entry is a vector. It's interesting how often seemingly obvious questions can't be answered. Thanks very much, leo and tbone, for all the detail.

We're planning to add a cleaner, built-in way to do this in 12.3.3-beta.

A nice addition in V12.3.3 — thanks very much.

With some quick experimentation, I notice that it works with all the DOpus.Create objects, such as vectors, a path created by scriptCommandData, a Date created by DOpus.Create.Date () but not by new Date (), a Vars object, a Command object, but not an array created by new Array. That's all very logical and straightforward, and will help in avoiding runtime errors.

"new Date" and "new Array" create JScript objects, so they won't have any Opus-specific functionality attached to them.

(On the other hand, things like DOpus.Create.Date() and DOpus.Create.Vector() create Opus's own objects, which may serve a similar purpose to the ones built into whichever scripting language is being used. Opus has separate objects for them to provide consistency between languages, and because some needed functionality isn't available in the languages' own objects.)