KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: WR Print Merge Replacement
PRODUCT: 4D | VERSION: 18 | PLATFORM: Mac & Win
Published On: July 12, 2021

Below is a method that can be used to replace the WR Print Merge method for use with 4D Write Pro

// WP_PrintMerge
// Replaces WR Print MErge
// $1 - WP object
// $2 - Table Number
// $3 - 1 to open print settings dialog, 0 to omit dialog

C_OBJECT($1;$wpObj)
C_LONGINT($2;$tblNum)
C_LONGINT($3;$printSettings)

C_POINTER($tblPtr)

$wpObj:=WP New($1)
$tblNum:=$2
$printSettings:=$3

$tblPtr:=Table($tblNum)

$recNum_l:=Selected record number($tblPtr->)

FIRST RECORD($tblPtr->)
$wpPrintObj:=WP New($wpObj)
WP FREEZE FORMULAS($wpPrintObj)
NEXT RECORD($tblPtr->)

Repeat
   WP INSERT BREAK($wpPrintObj;wk page break;wk append)
   WP INSERT DOCUMENT($wpPrintObj;$wpObj;wk append+wk freeze expressions)
   NEXT RECORD($tblPtr->)
Until (End selection($tblPtr->))

If ($printSettings=1)
   PRINT SETTINGS
End if

WP PRINT($wpPrintObj)

GOTO SELECTED RECORD($tblPtr->;$recNum_l)