V4RB, syntax for sorting of sets.

Charles Yeomans yeomans at desuetude.com
Wed Oct 6 12:56:00 CDT 2004


On Oct 6, 2004, at 8:11 AM, Ruslan Zasukhin wrote:

> On 10/6/04 2:38 PM, "Erik Mueller-Harder"
> <valentina-list at vermontsoftworks.com> wrote:
>
>> On Oct 5, 2004, at 17:11, Ruslan Zasukhin wrote:
>>
>>>     dim order as array  ?
>>>
>>>     order(1) = new VSortPair( f1, kAsc )
>>>     order(2) = new VSortPair( f3, kDesc )
>>>     order(3) = new VSortPair( f2, kAsc )
>>>
>>>     SortedSet = t.Sort( set, order )
>>>
>>>
>>> Do you like such syntax?
>>
>> It's a little verbose, but it's certainly clear and orderly.  I assume
>> the first array element would be the primary sort.  I'd be fine with 
>> it
>> -- but then I used to write in COBOL.  ;-)
>>
>>> It seems we have no other way for RB...
>>
>> Would this be impractical:
>>
>> SortedSet = t.Sort(set, f1, kAsc, f3, kDesc, f2, kAsc)
>>
>> or even:
>>
>> Set.Sort(f1, kAsc, f3, kDesc, f2, kAsc)
>
> But how I can do this in RB plugin ?!
>
> REALbasic do not allow functions with variable number of parameters.

But it does.  The ParamArray keyword was added to Rb 5.5. You declare a 
method like so --

Sub Sort(ParamArray sortPairs as VSortPair)

You then call it in code as follows.

Sort sortPair1, sortPair2, ..., sortPairN

sortPairs is passed into the method as an Rb array containing the 
elements sortPair1, ...,  sortPairN.  I don't know how this works from 
the plugin standpoint, but I am sure that you can figure it out.

Charles Yeomans



More information about the Valentina-beta mailing list