Macro to number bullets

Get help using and writing Nisus Writer Pro macros.
Post Reply
Jack Lint
Posts: 4
Joined: 2007-12-05 12:29:24

Macro to number bullets

Post by Jack Lint » 2007-12-05 13:20:22

I've finally taken the plunge to NWPro. I've got so much invested in my NW6.03 macros ... but time to covert I guess since my new Macs won't run Sys9.

[I sure miss the old 'record macro' option. Also the "macroize" button in the Find/Replace window. That was useful. I'll have to figure out the browser.]

I write really complex search/replace strings on the fly in the S/R window. Old version let me 'undo' from edit menu. Is there no 'undo' when (mis)typing in the new S/R window?

Here's why I posted today. I need a advice for converting/rebuilding my macro library; could someone point me in right direction. Also, right now I could use an elegant way to renumber bullets in a doc. My old macro snippet:

Code: Select all

If (SelectStart == SelectEnd) SetSelect(SelectStart,EndCharNum)
Find/Replace "•" "" "Wagt-g-o-O"
Thank you helpful Nisus folk.

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

Re: Macro to number bullets

Post by martin » 2007-12-05 15:36:55

Jack Lint wrote:Old version let me 'undo' from edit menu. Is there no 'undo' when (mis)typing in the new S/R window?
Nisus Writer Pro lets you undo/redo in the Find & Replace window just as you can in a normal document, eg: the menu Edit > Undo or Command + Z.
I need a advice for converting/rebuilding my macro library; could someone point me in right direction.
In general there's no resource that would help you convert your old macros as the NWP macro language is significantly different from that found in Classic. For help with the new macro language I would recommend the help built into NWP and the "Nisus Macro Reference" file found on the NWP disk image.

If you have specific questions, go ahead and ask them here. Also, I know the Nisus dartmouth list has a variety of knowledgeable users that made extensive use of macros in Classic Nisus Writer.
right now I could use an elegant way to renumber bullets in a doc. My old macro snippet:

Code: Select all

If (SelectStart == SelectEnd) SetSelect(SelectStart,EndCharNum)
Find/Replace "•" "" "Wagt-g-o-O"
I'm not sure I see what this replacement is supposed to do. To me it looks like it just deletes all list bullets. If you explained its intention I might be able to help you form an equivalent macro for NWP.

Jack Lint
Posts: 4
Joined: 2007-12-05 12:29:24

Post by Jack Lint » 2007-12-05 18:41:48

Here's the macro in its entirety. I use it all the time (in v6). It allows me to embed any symbol (here a bullet) repeatedly anywhere in my document and upon running the macro all are exchanged for sequence of 'soft' numbers - which I later convert to 'hard' (via 'convert variables to text') .

Code: Select all

//==================== MACRO Renumber
//	This macro replaces bullets with the automatic numbering tags (using the “Custom A” counter). If there is no selection, it does this from the insertion point to the end of the document. After the numbering is done, you can customize the starting number and the format of the numbers by using the “Define Numbers” menu command on the Insert menu.
If (SelectStart == SelectEnd) SetSelect(SelectStart,EndCharNum)
Find/Replace "•" "1" "Wagt-g-o-O"

Here's another macro that does the same thing but writes 'em out hard straight away.

Code: Select all

Select All
Find All "•" "gos"
s -> push (startends)
if (s -> error) goto reportError

number = s ->size/2
loop:
if (!s -> size) exit
SetSelect(s->pop, s-> pop)
clipboard = 0 + number
MacroPaste
number = number - 1
goto loop


//	probably low on memory.
reportError:
:1 "Error: unable to save all • positions."
Thanks for the help Martin.

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

Post by martin » 2007-12-06 00:49:42

To write a macro that replaces all of a certain bit of text (like your bullet) with literal characters codes, see this thread.

If you want to replace your bullets with automatic variables, that may not be possible in the general sense. Currently NWP doesn't have general purpose variables. However, if your bullets always appear at the start of a paragraph, then you can construct a macro that applies a custom list style which would do the automatic counting.

Let me know if you have any questions on this process.

Jack Lint
Posts: 4
Joined: 2007-12-05 12:29:24

Post by Jack Lint » 2007-12-08 18:07:53

Thanks. That'll work.

Post Reply