a custom Pair Structure

Is it possible to create a data structure that is IDENTICAL to the “PAIR” structure
but instead of being LEFT:RIGHT it is ROW:COLUMN

I have an app that uses PAIR for dictionary keys, but it is getting confusing to keep LEFT is ROW and RIGHT is Column
especially with LEFT is a common attribute for controls, etc… makes it confusing to keep the LEFTS easy to discern when reading the code etc.

Note : I need it to work the same as PAIR, otherwise I have to change hundreds of lines of code :frowning:

By “work the same” do you mean “must use the colon (:slight_smile: operator”?

Xojo doesn’t have an Operator_Tuple() does it? If it did, you could define your own types and call them using the colon notation.

if at all possible…
I have methods that accept pair as a parameter, and some that return pairs
would be optimal if I can replace “AS PAIR” with “AS customPAIR”
and then just change the .LEFT and .RIGHT

Keeping .LEFT and .RIGHT would be easy to do with a custom class.

What I don’t think would be possible would be for your custom class to do this:

Dim x as new CustomPair = 100: 200

you’d have to write it

Dim x as new CustomPair(100,200)

you mis-understand… I do NOT want to keep LEFT/RIGHT… I want ROW/COLUMN

Can you subclass Pair? Have your own Row/Column methods and just call the underneath left/right?

Didn’t think you could subclass a datatype
but how would that create a ROW:COLUMN ability?

Pair is a class. So maybe you can just add extension methods.

Ok… frustrating

I am trying to create this overload… and XOJO IDE keeps crashing when attempting to define it

SUB KeyRow(byref key as pair, assigns new_value as variant)

FUNCTION KeyRow(key as pair) as variant
  return key.left

It allows me to create the first, but as soon as I attempt to create the 2nd, the IDE crashes, over and over again

NOTE : ONLY CRASHES IN XOJO 2015r1! works as it should in 2014r3.2

not here
I’ve created this now 3 different ways in 2015r1

  1. add 2 new methods
    a) copied the declaration from your post for the SUB
    b) add new method to a class
    c) pasted
    d) copied the declaration from your post for the FUNCTION
    e) add new method to a class
    f) pasted

  2. variation on this where I copied pasted & added the code as well

  3. added new method & typed in declarations

if it crashes, maybe we can see something in crash report?

Yeah, I don’t get a crash, but these methods in a module give me Row and Column accessors for Pair…

[code]Function Row(extends p As Pair) As Variant
return p.Left
End Function

Function Column(extends p As Pair) As Variant
return p.Right
End Function[/code]

AH OK I managed to reproduce this myself working on something else


seems like if Norm can reproduce the issue and opens the ticket himself, it gets fixed immediately… I need to get Norm to reproduce my errors in the future… :slight_smile:

Being able to reproduce the error is 90% of fixing it.

I ran into this one while doing some other work & realized it was Dave’s issue
It is kind of tough to figure the steps to reproduce it and the fix was pretty quick

But yes , when I run into it it usually gets fixed ASAP if I can reproduce it right away
That’s not always the case

I accept Mastercard, PayPal and beer :stuck_out_tongue:

I thought you didn’t drink beer? XDC is fast approaching so I should work more to get the cc balance down. I think I owe a few rounds…

really should be


Dave’s issue (which he apparently has 2 of now) :stuck_out_tongue:

Me. Not drink beer ? You HAVE been to a conference haven’t you ?

Just have to duck Dana and the open bar police :stuck_out_tongue: