KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Clearing an anchor picture in 4D Write Pro
PRODUCT: 4D | VERSION: 17R4 | PLATFORM: Mac & Win
Published On: April 24, 2019

The command WP Add picture has the ability to add anchor pictures. Here is a utility method to clear out he anchor picture:

//---------------------------------------------------------------------------------
// Name: WP_CLEAR_ANCHOR_PICTURE
// Description: Method will clear an anchor picture in 4D WritePro.
//
// Parameters:
// $1 (POINTER) - 4D Write Pro obj
// $2 (TEXT) - ID of the picture object
// --------------------------------------------------------------------------------
C_POINTER($1;$wpObj)
C_TEXT($2;$ID)
C_LONGINT($i)
C_COLLECTION($docElements)

if (Count parameters=2)
   $wpObj:=$1
   $ID:=$2
  
   $docElements:=WP Get elements($wpObj->;wk type image)
  
   For ($i;0;$docElements.length-1)
  
    If ($docElements[$i].id=$ID)
       WP RESET ATTRIBUTES($docElements[$i];wk image)
       WP RESET ATTRIBUTES($docElements[$i];wk anchor origin)
       WP RESET ATTRIBUTES($docElements[$i];wk anchor section)
       WP RESET ATTRIBUTES($docElements[$i];wk anchor vertical align)
       WP RESET ATTRIBUTES($docElements[$i];wk anchor vertical offset)
       WP RESET ATTRIBUTES($docElements[$i];wk anchor layout)
       WP RESET ATTRIBUTES($docElements[$i];wk anchor page)
       WP RESET ATTRIBUTES($docElements[$i];wk anchor horizontal align)
       WP RESET ATTRIBUTES($docElements[$i];wk anchor horizontal offset)
    End if
  
  End for
  
End if


Note: This method does not delete the picture object that was created by WP Add picture but only clear the contents.


Here is an example of adding anchor picture in 4D Write Pro:

C_OBJECT($objPic)
C_TEXT($loc)

$loc:=Get 4D folder(Database folder)+"logo4D.jpg"
$objPic:=WP Add picture(WriteProArea;$loc)





When using the WP Add picture command, it is defaulted to created an ID with "Img#" where # increments starting at 1. Here is an example of clearing the same anchor picture:

WP_CLEAR_ANCHOR_PICTURE(->WriteProArea;"Img1")