Setting the current print position in device unitsΒΆ

setprintxy()

Set current print position in device units


SYNTAX

setprintxy(xpos, ypos)

Sets a new x and y origin for the next Sculptor print[h] command. Sculptor resets its current column and line numbers to match, rounding up to the next whole character and line position if necessary.

This enables draw operations to be mixed easily with Sculptor print commands, because the end position of an item drawn by a draw function can be used to determine a suitable position for print commands to continue. The co-ordinates of this position are then sent to setprintxy().

xpos, ypos

These may be fields, values or expressions, and should contain, in device units, the x and y co-ordinate of the position of the new origin for print[h] commands.

Note

The Sculptor system variable sys.Unit should be set to 0 (device units) before this function is called; its behaviour with other units is undefined. 0 is the default value for sys.Unit, so it is only necessary to reset it if a non-default value has been set.


EXAMPLE

In this example the DrawFormattedText() function is used to print the contents of a long text field between two print commands.

!temp PosX,,u2
!temp PosY,,u2
!temp IncY,,u2
!temp TextArray,,a200[40],,p

  print "This line precedes the formatted text"
  print tab(0);
  sys.Unit = 0
  getprintxy(PosX, Posy)                                          /* Move to start of left margin */
  IncY = DrawFormattedText(NULL, PosX, Posy, TextArray, \         /* Set the unit to device units */
         "Arial@10", 80 * sys.AvgCharWidth, 4* sys.LineHeight, \  /* Retrieve current print position */
         DT_WORDBREAK | DT_EDITCONTROL)                           /* Draw formatted text, returning the text height in IncY */
  setprintxy(PosX, Posy + IncY)                                   /* Set new print position, incrementing the y co-ordinate */
  print "This line follows the formatted text"

RELATED TOPICS

Reports

getprintxy()

print[h]

Draw operations

Device units

sys.Unit