4D v16WP SET ATTRIBUTES |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v16
WP SET ATTRIBUTES
|
WP SET ATTRIBUTES ( rangeObj | wpDoc ; attribName ; attribValue {; attribName2 ; attribValue2 ; ... ; attribNameN ; attribValueN} ) | ||||||||
Parameter | Type | Description | ||||||
rangeObj | wpDoc | Object |
![]() |
4D Write Pro range or document | |||||
attribName | String |
![]() |
Name of attribute to set | |||||
attribValue | String, Real, Boolean |
![]() |
New attribute value | |||||
The WP SET ATTRIBUTES command allows you to set the value of any attribute in a 4D Write Pro range or document. This command gives you access to any kind of 4D Write Pro internal attribute: character, paragraph, document, or image.
In the first parameter, you can pass either a 4D Write Pro range object (rangeObj) or a 4D Write document reference (wpDoc). A rangeObj is a part of a 4D Write Pro document that can be created by different commands. The following table provides the scope of the WP SET ATTRIBUTES command depending on the target object and attributes:
Parameter | Common attributes (except "verticalAlign") | Document-only attributes | Paragraph-only attributes | Character-only attributes (and "verticalAlign") |
rangeObj from WP Get paragraphs | paragraphs | document | paragraphs | paragraphs |
rangeObj from WP Get pictures | images | document | - | - |
rangeObj from WP Get range or | paragraphs for the range | document | paragraphs for the range (intersecting paragraphs) | characters for the range |
wpDoc | document | document | paragraphs for all the document | characters for all the document |
Common attributes (such as "margin", "padding", etc.) mean common to the document, paragraphs, and/or pictures.
For a comprehensive list of attributes to pass in attribName, as well as their respective values, please refer to the 4D Write Pro Attributes section.
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:
4D Write Pro Attributes
WP GET ATTRIBUTES
WP RESET ATTRIBUTES
Product: 4D
Theme: 4D Write Pro Language
Created: 4D v15 R4
4D Write Pro Reference ( 4D v16)