4D v16.3

SET PRINT MARKER

Home

 
4D v16.3
SET PRINT MARKER

SET PRINT MARKER 


 

SET PRINT MARKER ( markNum ; position {; *} ) 
Parameter Type   Description
markNum  Longint in Marker number
position  Longint in New position for the marker
Operator in If passed = move subsequent markers If omitted = do not move subsequent markers

The SET PRINT MARKER command enables the definition of the marker position during printing. Combined with the Get print marker, OBJECT MOVE or Print form commands, this command allows you to adjust the size of the print areas.

SET PRINT MARKER can be used in two contexts:

  • during the On Header form event, in the context of PRINT SELECTION and PRINT RECORD commands.
  • during the On Printing Detail form event, in the context of the Print form command. This operation facilitates the printing of customized reports (see example).
The effect of the command is limited to printing; no modification appears on the screen. The modifications made to the forms are not saved.

Pass one of the constants of the Form Area theme in the markNum parameter:

Constant Type Value
Form break0 Longint 300
Form break1 Longint 301
Form break2 Longint 302
Form break3 Longint 303
Form break4 Longint 304
Form break5 Longint 305
Form break6 Longint 306
Form break7 Longint 307
Form break8 Longint 308
Form break9 Longint 309
Form detail Longint 0
Form footer Longint 100
Form header Longint 200
Form header1 Longint 201
Form header10 Longint 210
Form header2 Longint 202
Form header3 Longint 203
Form header4 Longint 204
Form header5 Longint 205
Form header6 Longint 206
Form header7 Longint 207
Form header8 Longint 208
Form header9 Longint 209

In position, pass the new position desired, expressed in pixels.

If you pass the optional * parameter, all the markers located below the marker specified in markNum will be moved the same number of pixels and in the same direction as this marker when the command is executed. Warning: in this case, any objects present in the areas located below the marker are also moved.

When the * parameter is used, it is possible to position the markNum marker beyond the initial position of the markers that follow it — these latter markers will be moved simultaneously.

Notes:
  • This command modifies only the existing marker position. It does not allow the addition of markers. If you designate a marker that does not exist in the form, the command will not do anything.
  • The print marker mechanism in the Design mode is retained: a marker cannot go any higher than the one that precedes it, nor any lower than the one that follows it (when the * parameter is not used).

Example  

This complete example enables you to generate the printing of a three-column report, the height of each row being calculated on the fly according to the contents of the fields.
The output form used for printing is as follows:

The On Printing Detail form event was selected for the form (keep in mind that no matter what area is printed, the Print form command only generates this type of form event).
For each record, the row height must be adapted according to the contents of the "Actors" or "Summary" column (column having the most content). Here is the desired result:

The print project method is as follows:

 C_LONGINT(vLprint_height;$vLheight;vLprinted_height)
 C_STRING(31;vSprint_area)
 PAGE SETUP([Film];"Print_List3")
 GET PRINTABLE AREA(vLprint_height)
 vLprinted_height:=0
 ALL RECORDS([Film])
 
 vSprint_area:="Header" //Printing of header area
 $vLheight:=Print form([Film];"Print_List3";Form header)
 $vLheight:=21 //Fixed height
 vLprinted_height:=vLprinted_height+$vLheight
 
 While(Not(End selection([Film])))
    vSprint_area:="Detail" `Printing of detail area
    $vLheight:=Print form([Film];"Print_List3";Form detail)
  `Detail calculation is carried out in the form method
    vLprinted_height:=vLprinted_height+$vLheight
    If(OK=0) `CANCEL has been carried out in the form method
       PAGE BREAK
       vLprinted_height:=0
       vSprint_area:="Header" `Reprinting of the header area
       $vLheight:=Print form([Film];"Print_List3";Form header)
       $vLheight:=21
       vLprinted_height:=vLprinted_height+$vLheight
       vSprint_area:="Detail"
       $vLheight:=Print form([Film];"Print_List3";Form detail)
       vLprinted_height:=vLprinted_height+$vLheight
    End if
    NEXT RECORD([Film])
 End while
 PAGE BREAK `Make sure that the last page is printed

The Print_List3 form method is as follows:

 C_LONGINT($l;$t;$r;$b;$fixed_wdth;$exact_hght;$l1;$t1;$r1;$b1)
 C_LONGINT($final_pos;$i)
 C_LONGINT($detail_pos;$header_pos;$hght_to_print;$hght_remaining)
 
 Case of
    :(vSprint_area="Detail") `Printing of detail underway
       OBJECT GET COORDINATES([Film]Actors;$l;$t;$r;$b)
       $fixed_wdth:=$r-$l  `Calculation of the Actors text field size
       $exact_hght:=$b-$t
       OBJECT GET BEST SIZE([Film]Actors;$wdth;$hght;$fixed_wdth)
  `Optimal size of the field according to its contents
       $movement:=$hght-$exact_hght
 
       OBJECT GET COORDINATES([Film]Summary;$l1;$t1;$r1;$b1)
       $fixed_wdth1:=$r1-$l1  `Calculation of the Summary text field size
       $exact_hght1:=$b1-$t1
       OBJECT GET BEST SIZE([Film]Summary;$wdth1;$hght1;$fixed_wdth1)
  `Optimal size of the field according to its contents
       $movement1:=$hght1-$exact_hght1
       If($movement1>$movement)
  `We determine the highest field
          $movement:=$movement1
       End if
 
       If($movement>0)
          $position:=Get print marker(Form detail)
          $final_pos:=$position+$movement
  `We move the Detail marker and those that follow it
          SET PRINT MARKER(Form detail;$final_pos;*)
  `Resizing of text areas
          OBJECT MOVE([Film]Actors;$l;$t;$r;$hght+$t;*)
          OBJECT MOVE([Film]Summary;$l1;$t1;$r1;$hght1+$t1;*)
 
  `Resizing of dividing lines
          OBJECT GET COORDINATES(*;"H1Line";$l;$t;$r;$b)
          OBJECT MOVE(*;"H1Line";$l;$final_pos-1;$r;$final_pos;*)
          For($i;1;4;1)
             OBJECT GET COORDINATES(*;"VLine"+String($i);$l;$t;$r;$b)
             OBJECT MOVE(*;"VLine"+String($i);$l;$t;$r;$final_pos;*)
          End for
       End if
 
  `Calculation of available space
       $detail_pos:=Get print marker(Form detail)
       $header_pos:=Get print marker(Form header)
       $hght_to_print:=$detail_pos-$header_pos
       $hght_remaining:=printing_height-vLprinted_height
       If($hght_remaining<$hght_to_print`Insufficient height
          CANCEL `Move form to the next page
       End if
 End case



See also 

Get print marker
OBJECT GET BEST SIZE
OBJECT GET COORDINATES
OBJECT MOVE
PAGE BREAK
Print form
PRINT RECORD
PRINT SELECTION

 
PROPERTIES 

Product: 4D
Theme: Printing
Number: 709

 
HISTORY 

Modified: 4D 2003

 
ARTICLE USAGE

4D Language Reference ( 4D v16)
4D Language Reference ( 4D v16.1)
4D Language Reference ( 4D v16.2)
4D Language Reference ( 4D v16.3)