I post this for the benefit of those, like me, who have found the language and syntax surrounding rectangles to be confusing. I realized recently just how confusing it was to me when I tried to use the rectanglecenter( function. After studying the class video and demo, here is what I learned about the basics of rectangles.
A rectangle, in Panorama parlance, is a binary value that defines the coordinates of a rectangle object or other object. The rectanglecenter( function returns such a binary value. Obviously, to be useful, that rectangle binary needs to be assigned to an object (using changeobject or newformobject statements). So a rectangle object is what gets drawn on the form; the rectangle is a binary value defining the coordinates of that object. Just to add to the potential for confusion caused by the terminology, all objects have a rectangle property. Just think about it, lines have rectangle!
The inputs to the rectanglecenter( function are the rectangles from two objects, which the Panorama help page refers to as the larger rectangle and the smaller rectangle. Of course, they do not need to be larger and smaller than each other nor to be rectangle objects. To get the rectangle for object A, use objectinfo(“rectangle”,”A”).
To center object 2 in object 1, the code would be
changeobject 2,“rectangle”,rectanglecenter(objectinfo(“rectangle”,1), objectinfo(“rectangle”,2))
This assigns the newly calculated value for the centered rectangle value to object 2.
Voilá. Object 2 is centered in Object 1. [You may insert the quoted object names for object IDs 1 and 2 if the objects have been named.]
My confusion came from not distinguishing the rectangle, a binary value, from a rectangle object. If I could go back and change the terminology, I would use something like rectanglevalue to refer to the binary value of a rectangle. Probably too late for that.
Hopefully, I got this all correct.