# CurveShape ControlX and ControlY are arrays not treated as such; can't count them?

Hello,

I’d like to count how many control points are set for a passed CurveShape, but they are apparently half double properties (pardon the pun) and half arrays.

It’s possible to write and compile this:
i=MyCurveShape.ControlX(0)
so it’s indeed an array.

However:
1: “i=UBound(MyCurveShape.ControlX)”
results in a compilation error:
“There is more than one method with this name but this does not match any of the available signatures.”
2: autocomplete for “ControlX.” shows:
•FromString
•FromText
•IsInfinite
•IsNotANumber
•Parse
•ToString
•ToText
(i.e. the same list we get with a simple double datatype (lot of puns…))

The Language Reference says this, for CurveShape.ControlX:
•“Property (as double)”
•“ControlX(index as integer)” and “A zero-based array of control points”
Shouldn’t be “Property() as double” or “Property as array of double” or something similar? (I’ve failed to find another similar case in the LR).

So, how can one nicely (=not using a loop until an exception occurs) find the bound of a ControlX array?

Guessing here: I would assume that ControlX and ControlY as not properties, but are either computed properties or method pairs.

The LR does state the following.

If Order is set to 2, there are two control points. The line will bend first towards ControlX(0),ControlY(0), and then towards ControlX(1),ControlY(1). At the end points, the curve points directly at the associated control point. The curve is guaranteed to always stay within the polygon formed by the endpoints and the control points (if any).

Which I would assume to mean that the “Order” property is a means of setting/getting the number of control points.

1 Like

This doesnt mean its an array at all
It could just be a method that takes one parameter and returns an integer or double or whatever

This code says thats the case

``````
Dim tInfo As Introspection.TypeInfo = GetTypeInfo( CurveShape )

System.debuglog "METHODS"

Dim mInfo() As Introspection.MethodInfo = tinfo.GetMethods
For Each m As Introspection.MethodInfo In mInfo
System.debuglog m.Name
Dim pInfo() As Introspection.ParameterInfo = m.GetParameters
System.DebugLog "("
For Each p As Introspection.ParameterInfo in pInfo
System.DebugLog "   " + p.ParameterType.FullName
System.DebugLog "   ,"
Next
System.DebugLog ")"

Dim rInfo As Introspection.TypeInfo = m.ReturnType
If rInfo <> Nil Then
System.DebugLog " as " + rInfo.FullName
End If

Next

System.debuglog ""
System.debuglog ""
System.debuglog "PARAMETERS"

Dim pInfo() As Introspection.PropertyInfo = tinfo.GetProperties
For Each p As Introspection.PropertyInfo In pInfo
System.DebugLog p.Name + " as " + p.PropertyType.FullName
Next
``````
1 Like

Hello,
I first save the positions of a Graphicspath in an array
for the output I create a New Graphicspath in the ways that are possible

https://www.dropbox.com/s/iebujufv4dzlpgt/test-graphicsPath-2020R1.xojo_binary_project?dl=1

1 Like
1 Like

You’re both right about that possibility, but then it’s incorrectly reported under “Properties” in the LR.

I also thought of this, but it’s unclear wether this is a reliable assumption. For now, I’ll act as if it was.

Your “examples” contain a lot of tips for working with graphics; a useful reference! Thanks for sharing.
As for the original question (about ControlX), it’s more a general question (how do you know how many ControlX are for a given CurveShape even if you haven’t built it with your own code?).

Thank you all, I’ll assume the “Order” property is the relevant data here.

1 Like

In the Language Reference, ControlX is listed as a Property of CurveShape.

The Language Reference for ControlX describes it as “A zero-based array of control points (horizontal position).”

I bring this up again because I am trying to see the values that I have assigned ControlX and ControlY in the debugger. When I look at a CurveShape in the debugger, it has all the other properties (BorderColor, FillColor, Order etc.) but it does not have ControlX or ControlY. I was assuming that I would see ControlX as an array and then I would. be able to click on it and see the values of ControlX(0) and ControlX(1). (I am dealing with an Order = 2 cubic bezier CurveShape).

I cannot find in the debugger the current value(s) of ControlX. Is this a bug or am I not looking in the right place?

Well, as I played with this more, I guess I am just being tripped up in a very similar way to the original poster. The description in the LR that ControlX is a property that is a zero-based array is just wrong.

Sam Rowlands speculation that ControlX might just be a Computed Property is as reasonable as anything. When I think of it that way, it seems to encompass the behaviors that I see.

a test with points for external control

https://www.dropbox.com/s/ihbasw0moweg2t8/curve-shape-test.xojo_binary_project?dl=1