Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Creating TOC/Index using a lisp script

69 views
Skip to first unread message

RalfN

unread,
Jul 16, 2012, 10:57:13 AM7/16/12
to
Hello, I'm new to Lisp and programming.
Currently I'm using a few macro-api functions from QS 2.0 for some smaller tasks.
Some of these tasks have to do with editing index documents.

Now I would like to combine creating the index document and doing the editing tasks.

That means moving away from "Book -> Index..." and instead create an index document using a lisp script.

I found some code for creating a toc, but for Ileaf 5.
Because I had read somewhere that TOC and Index have similar syntax, I tested the following lines (ILeaf 6 and QS 2.0; the script into "System -> Custom -> Selection"):

(defun create-toc-for-all (container)
;creates a TOC for all docs in the conainer
(let (children child)
;get all the unselected children
(setq children (dt-children container :not-selected))
;select them
(while (setq child (pop children))
(tell child mid:set-props :selected t))
;create table of contents for all chidren
(toc-create-selected container)
))

Unfortunately it does not work. It seems that there happens nothing.
Are there any ideas to make it work?

Any help will be greatly appreciated!

Dick Margulis

unread,
Jul 16, 2012, 12:28:14 PM7/16/12
to
On 7/16/2012 10:57 AM, RalfN wrote:
>
> (defun create-toc-for-all (container)
> ;creates a TOC for all docs in the conainer
> (let (children child)
> ;get all the unselected children
> (setq children (dt-children container :not-selected))
> ;select them
> (while (setq child (pop children))
> (tell child mid:set-props :selected t))
> ;create table of contents for all chidren
> (toc-create-selected container)
> ))
>
> Unfortunately it does not work. It seems that there happens nothing.
> Are there any ideas to make it work?
>

If you actually copied and pasted your script into your post (rather
than rekeying it), it's possible that the typo in the third line from
the bottom ("chidren" instead of "children") is the cause of your problem.

RalfN

unread,
Jul 16, 2012, 1:21:07 PM7/16/12
to
Am Montag, 16. Juli 2012 18:28:14 UTC+2 schrieb Dick Margulis:
> On 7/16/2012 10:57 AM, RalfN wrote:
> >
> > (defun create-toc-for-all (container)
> > ;creates a TOC for all docs in the conainer
> > (let (children child)
> > ;get all the unselected children
> > (setq children (dt-children container :not-selected))
> > ;select them
> > (while (setq child (pop children))
> > (tell child mid:set-props :selected t))
> > ;create table of contents for all chidren
> > (toc-create-selected container)
> > ))
> >
> > Unfortunately it does not work. It seems that there happens nothing.
> > Are there any ideas to make it work?
> >
>
> If you actually copied and pasted your script into your post (rather
> than rekeying it), it's possible that the typo in the third line from
> the bottom ("chidren" instead of "children") is the cause of your problem.


Anything following a semicolon is a comment, so the typo will not take effect.
I didn't expect such a fast response! :-)

Dick Margulis

unread,
Jul 18, 2012, 8:38:31 AM7/18/12
to
Sorry, I'm an editor and book designer, not a Lisp programmer. I failed
to take note of the semicolon, but my eye was drawn to the typo. Please
ignore my irrelevant suggestion.

RalfN

unread,
Jul 18, 2012, 2:44:55 PM7/18/12
to
There is no reason to apologize. Glad to see that there are people left who aim to help in the ng.
Unfortunately, activity is very low, but I hope some lispers may read this posting, too.

RalfN

unread,
Aug 2, 2012, 2:04:04 PM8/2/12
to
>
> I found some code for creating a toc, but for Ileaf 5.

> (defun create-toc-for-all (container)
> ;creates a TOC for all docs in the conainer
> (let (children child)
> ;get all the unselected children
> (setq children (dt-children container :not-selected))
> ;select them
> (while (setq child (pop children))
> (tell child mid:set-props :selected t))
> ;create table of contents for all chidren
> (toc-create-selected container)
> ))

> Unfortunately it does not work. It seems that there happens nothing.
> Are there any ideas to make it work?

Randyl Kent Plampin helped me in his competent way to make it work and patiently answered my questions.
The original example in Weinberger's book was correct. The only reason it did not work at first was the missing code that actually invokes the example.

; Here is the missing code
(create-toc-for-all (dt-child-selected (dt-pointer-container)))

Now it works fine!
0 new messages