Question About Converting C++ Struct to Clarion Structure

Need some help converting this C++ Struct to a Clarion structure.

It’s clearly going to be a Group of some kind but the C++ syntax has me guessing:

struct Point {
Point(double x0, double y0) : x(x0), y(y0) {}
double x;
double y;
};

Here’s an example of the Struct being populated:

const Point test_polygon2[39] = {
Point(0, 1), Point(1, 1), Point(1, 2), Point(2, 2), Point(2, 3),
Point(3, 3), Point(3, 2), Point(4, 0), Point(5, 9), Point(6, 0),
Point(7, 2), Point(8, 0), Point(8, -2), Point(7, -3), Point(6, -2),
Point(5, -2), Point(4, -2), Point(3, -1), Point(2, -2), Point(1, -2),
Point(0, -3), Point(-2, -3), Point(-3, -4), Point(-4, -3), Point(-5, -3),
Point(-5, -2), Point(-4, -2), Point(-4, .5), Point(-5, .5), Point(-5, 1),
Point(-4, 1), Point(-4, 2), Point(-4, 4), Point(-3, 4), Point(-3, 2),
Point(-2, 2), Point(-2, 0), Point(-1, 1), Point(0, 1)
};

My current guess is a Group within a Group.

Thanks!

Other websites suggest a double is the same as a clarion BFLOAT8 datatype.
There is also this datatype in windows that uses longs.
POINT (windef.h) - Win32 apps | Microsoft Learn

So I’m guessing its going to be something like

_MyPoint   Group,Dim(39),Type
x0         bFloat8
y0         bFloat8
           End

MyPolygonPoint  Group
MyPoint         Like(_MyPoint)
                End
  Code
MyPolygonPoint[1].MyPoint.x0 = a number
MyPolygonPoint[1].MyPoint.y0 = a number

MyPolygonPoint[2].MyPoint.x0 = a number
MyPolygonPoint[2].MyPoint.y0 = a number

OR

_MyPoint   Group,Type
x0         bFloat8
y0         bFloat8
           End
  
MyPolygonPoint  Group
MyPoint         Like(_MyPoint),Dim(39)
                End
   Code
MyPolygonPoint.MyPoint[1].x0 = a number
MyPolygonPoint.MyPoint[1].y0 = a number

MyPolygonPoint.MyPoint[2].x0 = a number
MyPolygonPoint.MyPoint[2].y0 = a number

And when working with floats, the decimal seems to work well when needing to perform calculations, so the same may apply with the Clarion decimal datatype.

hth

POINTF                        GROUP, TYPE
x                               REAL
y                               REAL
                              END
1 Like

Thank you to all that responded.

The correct answer is:

POINT	GROUP, TYPE
x       REAL
y       REAL
        END

I have worked with “points” in C#/C++ and I knew that’s what a Clarion point structure should be. It was the extra “code” in the example C++ Struct that caused some confusion.

Your declaration may conflict with POINT defined in svapi files.

I think my moral of the story is, dont trust the search engines to look up data types.

1 Like