The top of, bottom of, left of, and right of functions can be applied to any object. The values returned are based upon the object's contents (drawing statements) and its children's contents. The values are expressed in the coordinates of the object. If the object has no contents, ESL returns values of zero for these functions.
Together, the values of these functions describe the smallest rectangle that encloses everything drawn in the object, including the object's children - even those that are invisible. If the object is a graphical region that has other graphical regions as children, the rectangle also encompasses the viewports of those children. The rectangle is not constrained by a graphical region's window size; the top, bottom, left, and/or right of the rectangle can lie either inside or outside the window.
Caution: Avoid using the top of, bottom of, left of, or right of functions for a scaled graphical region that contains text, or in a program whose defined screen size is different from the display resolution. Because you cannot scale text, these functions may not work when used at compile time. You can use these functions with text at runtime.
For a graphical object, the following values are returned:
Function |
Value Returned |
top [of] |
The topmost Y coordinate occupied by the contents of the object. |
bottom [of] |
The bottommost Y coordinate occupied by the contents of the object. |
left [of] |
The leftmost point X coordinate occupied by the contents of the object. |
right [of] |
The rightmost X coordinate occupied by the contents of the object. |
In the example below, the user wants to add pattern Picture to disabled key Logo. This pattern is added 10 positions to the right of the previously existing contents of Logo. The variable MaxLogo shows an estimated maximum (MaxLogo), beyond which no new contents will be added; if Logo is already to the right of that value, an error occurs.
if (right of Logo < MaxLogo) then # Any more room?
add to Logo
move to (right of Logo + 10) Height
pattern Picture
else
make ErrorMessage visible end if