nisus.com
https://www.nisus.com/forum/

paragraph style as a condition
https://www.nisus.com/forum/viewtopic.php?f=17&t=6029
Page 1 of 1

Author:  js [ 2015-04-05 15:18:20 ]
Post subject:  paragraph style as a condition

In a document myfile I would like to check the paragraph style of the selection. This works fine like so:

Code:
Document.open  "~/Documents/myfile"
$doc = Document.active
$sel = $doc.textSelection
$parStyle = $sel.paragraphStyle
prompt $parStyle


Now let‘s say the prompt says
Quote:
Paragraph Style "Normal"

How must I formulate a condition: If Paragraph Style is "Normal" then do suchandsuch?
Code:
If $parStyle = "Normal"
do such and such
end
does not work.

Author:  capvideo [ 2015-04-05 20:23:12 ]
Post subject:  Re: paragraph style as a condition

Judging from my own code, what you want is $parStyle.name. TextSelection.paragraphStyle returns a style object; the property “name” on that object contains the style’s name as text. Getting the style’s name as text allows you to compare the style name to some text of your own.

Code:
$parName = $parStyle.name
If $parName == "Normal"
    do such and such
End


You can see this in the Nisus Macro Reference (under the Help menu) in the DOCUMENT OBJECTS section, Style Object, Style Object Properties. There are quite a few useful properties there for you to use in your macros.

Author:  js [ 2015-04-05 23:36:39 ]
Post subject:  Re: paragraph style as a condition

Perfect. Thank you.

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/