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

Macro language syntax or bug?
https://www.nisus.com/forum/viewtopic.php?f=17&t=4291
Page 1 of 1

Author:  phspaelti [ 2011-05-21 07:10:06 ]
Post subject:  Macro language syntax or bug?

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:
$docname = Document.displayName

But this kept giving me errors. I know that one can write the following
Code:
$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:
Document.selectedFloatingContent

but this also gave me an error when I tried to use it. So is the manual in error?

Author:  Kino [ 2011-05-21 07:24:25 ]
Post subject:  Re: Macro language syntax or bug?

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:
$docname = Document.displayName
That has never worked.

Quote:
I should note also that the manual contains the following:
Code:
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:
$doc = Document.active
exit $doc.selectedFloatingContent.anchorTextRange

Author:  phspaelti [ 2011-05-21 19:28:30 ]
Post subject:  Re: Macro language syntax or bug?

Thanks, Kino

Author:  martin [ 2011-05-23 09:09:07 ]
Post subject:  Re: Macro language syntax or bug?

Kino is exactly right. To clarify, something like this is an object type command:
Code:
$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:
$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:
$doc = Document.active
$ext = $doc.filePath.filePathExtension

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