I can’t find documentation for the Collection object
implemented in Basic. There only is an insufficient help text.
Generally, and because the mentioned help doesn’t contain examples, I would like to know…
See subject.
- Collection object was implemented in (pre-)OOo times to support respective VBA object. Hence, the VBA documentation may be used, even if we still lack a good own documentation.
- Of course, ordering inserted items may be useful: by default (without keys), the new items are appended to the end of the collection (so you may refer to them using the index equal to the previous collection length); or to an hash-grouped position of the key (when keys are used); but when before/after are used, you define the position explicitly; that e.g. may be used to create (custom-)sorted collections. The source code is here.
Thanks and yes, I thought of this for a moment. However, I cannot imagine it as a realistic use-case. A sorting algorithm based on the before/after could only be a primitive and inefficient insertsort
where the position for insertion would be found with the help of a Basic-loop
.
No, if you insert in a single function, where all the objects positions are known. But well, I’m not someone who can speak about realistic use cases, since all my use of Basic over last 8 years or so are just others’ scripts and their problems, not developing actual Basic solutions… Wait, one realistic use case stems from the “implemented to support VBA” fact: that is, the use case is running already existing VBA code using these keywords - no matter if the author used them for a good reason or not
“Known” by what kind of information? How achieved?
Don’t worry!
As so often I don’t ask for a solution, but for better understanding of a situation / documentation / issue.
Searching the ask site or the bugtracker I got the impression that Collection
objects are rarely used. They also aren’t even mentioned in Andrew’s texts.
Since I had reasons once in a while to consider the usage of a Collection
, I stumbled over lacking documentation, (what I see as) outdated notations, missing methods, and at least one serious bug …
Now I considered a Basic-internal
enhancement and bugfix …
There are strange thoughts in the head of a retired teacher, probably.
E.g., read from file - again, just inventing an option.