Function GraLine() Foundation

Draws a straight line or a portion of a polygon.

GraLine( [<oPS>], [<aStartPoint>], <aEndPoint> ) --> lSuccess
The argument <oPS> specifies the presentation space in which a line is drawn. If the current window is an XbpCrt window, <oPS>is optional. If it is NIL, the return value of SetAppWindow():presSpace() is used. In all other cases <oPS> is not optional. It must be created either using XbpPresSpace():new() or a "Micro PS" must be requested from an Xbase Part using the method:lockPS(). After graphic output the Micro PS must be released with :unlockPS().
<aStartPoint> := { <nXStart>, <nYStart> }
<aStartPoint> is an array of two elements which determines the coordinates for the origin of the line. The first element <nXStart>specifies the x coordinate and the second element <nYStart>specifies the y coordinate. The unit for the coordinates depends on the coordinate system defined for the presentation space. If no presentation space is defined, the values for the coordinates are given in pixels, which is the unit for a window. The origin for the coordinates (the point {0,0}) is at the lower left. If <aStartPoint> is not specified, the line begins at the current pen position.
<aEndPoint> := { <nXEnd>, <nYEnd> }
<aEndPoint> is an array of two elements which contains the coordinates for the end point of the line.

The return value of GraLine() is .T. (true) if the line was drawn, otherwise it is .F. (false). If the return value is .F., the cause of error can be determined using GraError().


The function GraLine() is a graphic primitive which draws a line in a presentation space. In order to draw a line, two points must be specified. If the first point <aStartPoint> is not specified, the line begins at the current pen position. Various line types are available (solid, dashed, dotted, etc.). Line types must be selected before output of the line by calling the function GraSetAttrLine(). After GraLine() returns, the pen is positioned at <aEndPoint>.

Drawing lines

// The example draws two lines. The second line begins 
// at the end of the first line. 


   SetColor("N/W")                     // fill window with pale gray 

   GraLine( NIL, {10,10}, {100,100} )  // line with starting point 
   GraLine( NIL,    NIL , {200, 50} )  // line continues 

   Inkey(0)                            // wait for key press 

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.