Using ST SET ATTRIBUTES with a Write Pro object

In the docs it says:
"If you pass the optional * parameter, this indicates that the object parameter is an object name (string). "

But this does not work when adding style information to a Write Pro object.
For example:

$WPObjectname:=“oWPdoc”
ST SET ATTRIBUTES(*;$WPObjectname;1;15;Attribute font name;“Arial”;Attribute text size;14)

No error is generated, but the text is not styled.

But if I do this:

ST SET ATTRIBUTES(oWPdoc;1;15;Attribute font name;“Arial”;Attribute text size;14)

It works - the text is set in Arial 14.

oWPdoc is an object so the first syntax should work.

What am I doing wrong?

The confusion came from the name “object”

If “object” is a Form object then use *
If “object” is a variable then don’t use *

The problem is that the variable of a Write Pro zone is also an object (but here we talk about the type of the variable…) :roll:

So oWPdoc is a variable (Write Pro zone) and his type is an Object BUT it is NOT a Form object.

You understand this time :lol:

OK I understand. Thanks Manuel!

Hi Pat,

Are you trying to set the document’s font/size? Or are you trying to set only the first 15 characters of something?

Assuming that “oWPdoc” is an reference to the WriteProArea form object, I believe your code:

<code 4D>
ST SET ATTRIBUTES(oWPdoc;1;15;Attribute font name;“Arial”;Attribute text size;14)
</code 4D>

will do one of three things, depending on the presence or absence of text in the document.

To clearly observe the behavior I’ve described above, try adding a red text color to your code:

<code 4D>
ST SET ATTRIBUTES(oWPdoc;1;15;Attribute font name;“Arial”;Attribute text size;14;Attribute text color;“red”)
</code 4D>

If you are trying to set the font and font size for the entire document, you might be better off (and it would be clearer) if you call:

<code 4D>
WP SET ATTRIBUTES(oWPdoc;wk font;“Arial”;wk font size;14)
</code 4D>

Passing the document reference (“oWPdoc”) to the http://doc.4d.com/4Dv16R5/4D/16-R5/WP-RESET-ATTRIBUTES.301-3494590.en.htmlWP SET ATTRIBUTES> command will style the entire document – provided the passed http://doc.4d.com/4Dv16R5/4D/16-R5/4D-Write-Pro-Attributes.300-3494591.en.htmlattributes> can be applied to all document elements.

  • Jeremy