Page 1 of 1
Macro language syntax or bug?
Posted: 2011-05-21 07:10:06
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:
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:
but this also gave me an error when I tried to use it. So is the manual in error?
Re: Macro language syntax or bug?
Posted: 2011-05-21 07:24:25
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:
That has never worked.
I should note also that the manual contains the following:
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
Re: Macro language syntax or bug?
Posted: 2011-05-21 19:28:30
by phspaelti
Thanks, Kino
Re: Macro language syntax or bug?
Posted: 2011-05-23 09:09:07
by martin
Kino is exactly right. To clarify, something like this is an object
type command:
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