Macro language syntax or bug?

Get help using and writing Nisus Writer Pro macros.
Post Reply
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Macro language syntax or bug?

Post by phspaelti »

Today I was experimenting with macros in NW 2.0. I thought I remembered that one should be able to write something like this:

Code: Select all

$docname = Document.displayName
But this kept giving me errors. I know that one can write the following

Code: Select all

$doc = Document.active
$docname = $doc.displayName
and this works fine, but I am still wondering about the above. Am I misremembering this, or does NW 2.0 have a bug?

I should note also that the manual contains the following:

Code: Select all

Document.selectedFloatingContent
but this also gave me an error when I tried to use it. So is the manual in error?
philip
Kino
Posts: 400
Joined: 2008-05-17 04:02:32

Re: Macro language syntax or bug?

Post by Kino »

phspaelti wrote:Today I was experimenting with macros in NW 2.0. I thought I remembered that one should be able to write something like this:

Code: Select all

$docname = Document.displayName
That has never worked.
I should note also that the manual contains the following:

Code: Select all

Document.selectedFloatingContent
but this also gave me an error when I tried to use it. So is the manual in error?
“Document” stands for Document object as the cross-reference shows (double click on “Document”). Try something like this.

Code: Select all

$doc = Document.active
exit $doc.selectedFloatingContent.anchorTextRange
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Macro language syntax or bug?

Post by phspaelti »

Thanks, Kino
philip
User avatar
martin
Official Nisus Person
Posts: 5228
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Macro language syntax or bug?

Post by martin »

Kino is exactly right. To clarify, something like this is an object type command:

Code: Select all

$doc = Document.active
It's a way of getting a specific object, which is then assigned to "$doc". Once you have that specific object, you can start using its properties.

Ideally it should be possible to write something like:

Code: Select all

$docname = Document.active.displayName
But right now the intermediate step of assigning "$doc" is needed when using the object type commands. Though you can chain specific object properties/commands, eg:

Code: Select all

$doc = Document.active
$ext = $doc.filePath.filePathExtension
Post Reply