4D v17

WP SET ATTRIBUTES

Home

 
4D v17
WP SET ATTRIBUTES

WP SET ATTRIBUTES 


 

WP SET ATTRIBUTES ( targetObj ; attribName ; attribValue {; attribName2 ; attribValue2 ; ... ; attribNameN ; attribValueN} ) 
Parameter Type   Description
targetObj  Object in Range or element reference or 4D Write Pro document
attribName  Text in Name of attribute to set
attribValue  Text, Number, Longint array, Real array, Picture, Date in New attribute value

The WP SET ATTRIBUTES command allows you to set the value of any attribute in a range, element reference or document. This command gives you access to any kind of 4D Write Pro internal attribute: character, paragraph, document, table, or image.

In the first parameter, you can pass :

  • a range, or
  • an element reference (header / footer / body / table / row / paragraph / anchored or inline picture), or
  • a 4D Write Pro document

In attribName, pass the name of the attribute to set for the target and in attribValue, pass the new value to set. For a comprehensive list of attributes to pass in attribName, as well as their scope and respective values, please refer to the 4D Write Pro Attributes section.

You can pass as many attribName / attribValue pairs as you want.

Note: If you need to set multiple attributes for the same target, it is more optimized to use a single call to WP SET ATTRIBUTES with all attribute/value pairs, rather than calling WP SET ATTRIBUTES several times. 

In this 4D Write Pro area, you selected a word:
 

 

If you execute the following code:
 

 $range:=WP Get selection(*;"WParea") //get the selected range
 
  // set the shadow offset in pt for the selected text
 WP SET ATTRIBUTES($range;wk text shadow offset;1)
  //set the paragraph padding
 WP SET ATTRIBUTES($range;wk padding;1)
  //define a border of 10 pt
 WP SET ATTRIBUTES($range;wk border style;wk solid;wk border width;10)
  //set the border colors
 WP SET ATTRIBUTES($range;wk border color;"blue";wk border color bottom;"#00FA9A";wk border color right;"#00FA9A")

 

You get the following result:
 

This example illustrates the use of wk inside and wk outside constants:
 

 $wpRange:=WP Get selection(writeProdoc)
 WP SET ATTRIBUTES($wpRange;wk border style+wk inside;wk dotted)
 WP SET ATTRIBUTES($wpRange;wk border style+wk outside;wk solid)
 WP SET ATTRIBUTES($wpRange;wk border color+wk outside;"#00FA9A")

 

Assuming all of the contents were selected, the result is:
 

You want to set a background image for the document:

 C_OBJECT(WParea)
 WParea:=WP New
 
 READ PICTURE FILE("C:\\Pictures\\boats.jpg";$picture)
 
 WP SET ATTRIBUTES(WParea;wk background image;$picture)

The result is:

You want to set a background image that covers the whole printable area:

 C_OBJECT(WParea)
 WParea:=WP New
 
 READ PICTURE FILE("C:\\Pictures\\boats.jpg";$picture)
 
 WP SET ATTRIBUTES(WParea;wk background image;$picture)
 WP SET ATTRIBUTES(WParea;wk background clip;wk paper box)
 WP SET ATTRIBUTES(WParea;wk background origin;wk paper box)

The result is:

Note: The paper box value is only applicable to documents and sections.

You want to set tabs at varying intervals and designate different characters as the leading character:

 C_OBJECT(WParea)
 
 ARRAY TEXT(_position;0)
 ARRAY LONGINT(_type;0)
 ARRAY TEXT(_leadings;0)
 
 APPEND TO ARRAY(_position;"3cm")
 APPEND TO ARRAY(_type;wk left)
 APPEND TO ARRAY(_leadings;".")
 
 APPEND TO ARRAY(_position;"7.5cm")
 APPEND TO ARRAY(_type;wk right)
 APPEND TO ARRAY(_leadings;".")
 
 APPEND TO ARRAY(_position;"9cm")
 APPEND TO ARRAY(_type;wk center)
 APPEND TO ARRAY(_leadings;".")
 
 APPEND TO ARRAY(_position;"12cm")
 APPEND TO ARRAY(_type;wk decimal)
 APPEND TO ARRAY(_leadings;"~")
 
 APPEND TO ARRAY(_position;"2cm")
 APPEND TO ARRAY(_type;wk left)
 APPEND TO ARRAY(_leadings;"")
 
 $range:=WP Get selection(WParea)
 WP SET ATTRIBUTES($range;wk tab stop offsets;_position)
 WP SET ATTRIBUTES($range;wk tab stop types;_type)
 WP SET ATTRIBUTES($range;wk tab stop leadings;_leadings)

The result is:



See also 

4D Write Pro Attributes
WP GET ATTRIBUTES
WP RESET ATTRIBUTES

 
PROPERTIES 

Product: 4D
Theme: 4D Write Pro Language
Number: 1342

This command can be run in preemptive processes

 
HISTORY 

Created: 4D v15 R4
Modified: 4D v16 R4
Modified: 4D v16 R6

 
ARTICLE USAGE

4D Write Pro Reference ( 4D v17)