View Single Post
I apologize in advance for this insanely lengthy post, but while looking for a way to restart page numbering within an OG document at "1" so that I don't have to put my manually-crafted TOC as the last canvas to avoid screwing up the other page numbers, I ran into this thread.

The problem with piling on features like "insert table of contents" is that the ramifications of doing it properly and in a way that meets everyone's needs readily cascades into the evil realm of bloatware.

Is there another way to achieve the same goal, perhaps a more subtle enhancement that we could leverage? I can think of one way...

Suppose in addition to using pre-defined variables, we could define our own variables like this:

Quote:
<%myvariable="some fixed value"%>
To keep this as simple as possible, let's say that the name you choose for your variable ("myvariable" in this case) cannot be the same as any of the pre-defined variables, and further, that it is an error to define the same variable more than once within the same OG document.

(That neatly avoids several implementation ramifications that I'll refrain from describing here. It should be also be noted that these are not "variables" in that their values are prohibited from varying. Nevertheless, we resist the inclination to call them "parameters" in deference to simplicity.)

Now, we could define a particular variable in one place and use it in many other places. Here's a silly example:

Canvas 1:
Quote:
Foo is <%foo%>
Canvas 2:
Quote:
<%foo="hello, world!"%>
Canvas 3:
Quote:
Foo will always be <%foo%>
These would, of course, show up like this:

Canvas 1:
Quote:
Foo is hello, world!
Canvas 2:
Quote:
hello, world!
Canvas 3:
Quote:
Foo will always be hello, world!
(If I wanted, I could "hide" the definition on Canvas 2 by settings its text color the same as the canvas background color or by putting it in a hidden layer.)

Less silly would be if we could define a variable to take on the value of another variable, particularly one of the built-in ones, like this:

Quote:
<%myname=Canvas%><%mypage=#%>
Now things are more interesting:

Canvas 1:
Quote:
Table of Contents:
<%section1_title%> <%section1_page%>
<%seciton2_title%> <%section2_page%>
Canvas 2:
Quote:
...<%section1_title=Canvas%><%section1_page=#%>...
Canvas 3:
Quote:
This is the second page of the first section.
Canvas 4:
Quote:
...<%section2_title=Canvas%><%section2_page=#%>...
(I would change the names of canvases 2 and 4, of course, to whatever I wanted to appear in the table of contents.) Although I would need to create variables for each section and manually place them on the table of contents canvas, the table would automatically stay up-to-date as I insert canvases or rename them (which takes advantage of the convention of using the canvas name as a page or section title.) If I were to move sections around, of course, I'd need to manually shuffle the table of contents, but regardless, the page numbers would always remain correct even if I didn't.

One could imagine additional, minor embellishments to take care of some other misfeatures. For example, I use <%Document%> and <%Canvas%> on a master canvas to automatically "title" the pages of my document. Unfortunately, this forces me to omit the ".graffle" from any of these document files' names. What if OmniGroup extended variable assignment to support a few simple functions, for example:

Quote:
<%pagetitle=replace(Document,".graffle","")>
might take the value of the built-in Document variable and replace the trailing ".graffle" with an empty string, effectively removing it.

Back to the "table of contents" problem, there's still one remaining issue, far as I'm concerned. What if I want to force the second page (canvas), that is, the one after the table of contents, to be numbered as page "1"? It would be tempting to do it this way:

Canvas 2:
Quote:
...<%section1_title=Canvas%><%#=1%><%section1_page=#%>...
(Notice how I sneakily assigned the value "1" to the built-in variable "#", which one might assume forces OG to begin numbering pages going forward starting again at "1". But that would require yet another enhancement...)

Then there's the issue of how user-defined variables are interpreted when they appear on a master canvas. Would that be possible given the assumption that defining the same variable more than once in an OG document is prohibited?

Remember what I said at the beginning about cascading ramifications... though I could think of some really cool things to do if we relaxed this restriction a bit, allowed recursive variable substitution, and...