Discussion:
table rows in a galley
(too old to reply)
Jennings, Jared L CTR USAF AFMC 46SK/CCI
2008-10-01 21:27:48 UTC
Permalink
I want to send things into a galley which use symbols defined in the
scope which encloses the galley. This does not seem possible.

I'm making a report in Lout; the formatting of the report doesn't change
much but the contents do. So I'm trying to put the formatting in one
place and the content in another, consulting slidesf and slides as I
make a new document type.

In particular, there's a table whose first row is always the same. I
want the invariant part of the table in the document type, and only its
contents in the document itself. Just as a normal document has a
FootPlace on a normal page, my document wants to have a place for data
rows for this table. But when I make a galley inside the table, things I
send to the galley don't have access to the scope of the table: for
example, @Rowa is undefined or misspelt.

A trivialized example follows.

---------
@SysInclude { doc }
def @FooGalley {
@Galley
@DP
@FooGalley
}
export @Red @Blue
def @SpecialRed {
def @Red right x { { red } @Colour x }
def @Blue right x { { blue } @Colour x }
@CurveBox {
this is a @Red { special red } item
@DP
@FooGalley
}
}
import @SpecialRed
def @FooItem into { @FooGalley&&preceding } right x { x }

@Doc @Text @Begin
4i @Wide 5i @High @Box @SpecialRed
@FooItem foo
@FooItem { @Red bar }
@End @Text
---------

erlang:~/reports $ lout -p foo
lout file "foo":
25,12: symbol @Red unknown or misspelt







this is a special red item

foo

@Red bar


---------

Is there any way to do what I'm trying to do?
Dominique Crétel
2008-10-01 21:34:56 UTC
Permalink
Hello,
Is there any binary version for Windows?
Thanks.
Remo Dentato
2008-10-02 05:55:29 UTC
Permalink
I was working to create one with mingw.The problem is that first pass
on a file always succeed, the second pass sometimes fails. I think it
has to do with reading the .ld files back but I've not been able to
nail down where this happen.

At this point I'll wait for Jeff to release the 3.38 and will try again on that.

Remo
Ludovic Courtès
2008-10-02 09:15:10 UTC
Permalink
Hi,

"Jennings, Jared L CTR USAF AFMC 46SK/CCI"
Post by Jennings, Jared L CTR USAF AFMC 46SK/CCI
---------
@SysInclude { doc }
@Galley
@DP
@FooGalley
}
@CurveBox {
@DP
@FooGalley
}
}
@Doc @Text @Begin
@FooItem foo
@FooItem { @Red bar }
@End @Text
---------
erlang:~/reports $ lout -p foo
this is a special red item
foo
@Red bar
---------
It's the invocation "@FooItem { @Red bar }" that fails: `@Red' is not a
globally visible symbol. Instead, you should write, e.g.,
"@FooItem { @SpecialRed @Open { @Red bar } }" so that `@Red' is actually
visible at the invocation site.

(That doesn't answer the rest of your message, but we'll see that
later. ;-))

Ludo'.
Jennings, Jared L CTR USAF AFMC 46SK/CCI
2008-10-02 13:47:11 UTC
Permalink
Post by Ludovic Courtès
globally visible symbol. Instead, you should write, e.g.,
visible at the invocation site.
That works flawlessly. Thank you :) Unfortunately this only means that
my simple example fails to mirror my real problem.
Post by Ludovic Courtès
(That doesn't answer the rest of your message, but we'll see that
later. ;-))
:) Here's a better example. It seems the problem with this one is not
with getting the right symbols in scope, but something else.

--------

@SysInclude { doc }
@SysInclude { tbl }

def @FooGalley { @Galley @FooGalley }
def @MyTbl {
@Tbl rh { yes } w { expand }
aformat { @Cell A | @Cell B }
{
@Rowa A { country } B { population }
@FooGalley
}
}
def @Country into { @FooGalley&&preceding }
named name {} named population {} {
@Tbl {} @Open { @Rowa A { name } B { population } } }
@Doc @Text @Begin
@DP stuff @DP
4i @Wide 5i @High @MyTbl
@DP other stuff
@Country name { Molduria } population { 103 }
@End @Text

---------

Errors:

first run after rm *.ld *.li:
lout file "foo":
20,1: no @FooGalley galley target precedes this
@FooGalley&&preceding

second run: none

third and following runs:
lout file "foo.ld" (from "foo" line 16):
187,2: galley @Country deleted (never attached)

---------

Output (all runs) is "stuff" followed by 5 inches vertical whitespace
followed by "other stuff": the table is completely blank. If I take the
@FooGalley out of the @Tbl, the row with the headings becomes visible.

---------

I expect that there should be a @FooGalley galley target preceding the
reference to it, because the @MyTbl comes before the @Country.
Ludovic Courtès
2008-10-03 09:52:59 UTC
Permalink
Hi,

"Jennings, Jared L CTR USAF AFMC 46SK/CCI"
Post by Jennings, Jared L CTR USAF AFMC 46SK/CCI
--------
@SysInclude { doc }
@SysInclude { tbl }
@Tbl rh { yes } w { expand }
{
@Rowa A { country } B { population }
@FooGalley
}
}
named name {} named population {} {
@Tbl {} @Open { @Rowa A { name } B { population } } }
@Doc @Text @Begin
@DP stuff @DP
@DP other stuff
@Country name { Molduria } population { 103 }
@End @Text
---------
@FooGalley&&preceding
There must be an `@FooGalley' invocation at some point before the
`@Country' invocation, otherwise `@Country' has no galley to get in.

(Esthetically, you could handle this by having an `@BeginCountries'
symbol that invokes `@FooGalley'.)

Thanks,
Ludo'.
Valeriy E. Ushakov
2008-10-03 15:16:30 UTC
Permalink
Post by Jennings, Jared L CTR USAF AFMC 46SK/CCI
@Tbl rh { yes } w { expand }
{
@Rowa A { country } B { population }
@FooGalley
}
}
named name {} named population {} {
@Tbl {} @Open { @Rowa A { name } B { population } } }
There are several problems with this (though my Lout is getting quite
rusty, so take this with a grain of salt).

First, @Rowa inside @Country gets the formatting from the @Tbl
instance you @Open, not from the "target" table, and so that @Rawa is
effectively a no-op.

Second, your @FooGalley must use vertical concatenation (inside the
definition and in @MyTbl).

Third, if you fix the two above you will run into the requirement for
a galley to have single column mark - which ruins the table that
requires separate column marks to line up table columns.

SY, Uwe
--
***@stderr.spb.ru | Zu Grunde kommen
http://snark.ptc.spbu.ru/~uwe/ | Ist zu Grunde gehen
Valeriy E. Ushakov
2008-10-03 16:40:48 UTC
Permalink
Post by Valeriy E. Ushakov
There are several problems with this (though my Lout is getting quite
rusty, so take this with a grain of salt).
Something along the following lines might work, but I didn't really
try to make it foolproof or flexible. I have a vague feeling that you
are not splitting responsibilities between the generating program and
lout quite right and that makes you write lout code that is more
complex than necessary.


# "meta-galley", helps to get rid of hordes of
# trivial galley definitions
def @Send
left @Target
named @
right @Component
{ @Component }
right galley
{
def @Enclose right component { @ component }
galley
}

def @CPlace { @Galley }
def @PPlace { @Galley }
def @BounceRows { @Galley // @BounceRows }

def @MyTbl {
import @Tbl
def @RepeatRowa {
@Rowa A { @CPlace } B { @PPlace }
// @RepeatRowa
}

@BounceRows //
@Tbl rh { yes } w { expand }
aformat { @Cell { @Right A } | @Cell B }
{
@Rowa A { country } B { population }
// @RepeatRowa
}
}

def @Country named name {} named population {} {
{ @BounceRows&&preceding } @Send {
{ @CPlace&&following } @Send { name }
{ @PPlace&&following } @Send { population }
}
}


PS: http://www.stderr.spb.ru/~uwe/lout/essays/essays.html (*shamless
plug* :) has some examples that demonstrate how to work with scopes,
galleys and xrefs.

SY, Uwe
--
***@stderr.spb.ru | Zu Grunde kommen
http://snark.ptc.spbu.ru/~uwe/ | Ist zu Grunde gehen
Jeff Kingston
2008-10-07 22:59:06 UTC
Permalink
But when I make a galley inside the table, things I send to
the galley don't have access to the scope of the table: for
Even worse (if I understand what you are trying to do correctly),
every galley has a single column mark, and so you can't pass a
table row, which has several column marks, through a galley;
or rather, you can, but what comes out the other end has a
single column mark and will be treated as a single column.
I have a vague feeling that you are not splitting responsibilities
between the generating program and lout quite right and that makes
you write lout code that is more complex than necessary.
I agree with his comment. If you are generating the Lout source with
a program then you probably don't need a layer of your own definitions
at all; just go ahead and generate the tables you need.

Definitions with parameters are much easier to work with than galleys,
and they are often the best way to separate format from content. Make
a definition with one parameter for each distinct element of content,
and a body containing all the layout. When the content is an arbitrary
number of table rows and columns, you have to do something to indicate
within the content where the column and row breaks are. Here is an
example using / and | (see the Expert's Guide) rather than @Tbl:

def @Seasons
right body
{
Winter | Spring | Summer | Autumn
/
body
}

and then you can write

@Seasons
{
Skiing | Floods | Droughts | More droughts
/
Cold | Wet | Hot | Less hot
}

which would make a table with four columns and three rows. The
value of "body" can have any number of column and row marks, and
these will be merged correctly with column and row marks at the
point where "body" is used inside the definition of @Seasons.
Using Lout primitives avoids the scoping problems with @Tbl.

Jeff
Jennings, Jared L CTR USAF AFMC 46 SK/CCI
2008-10-09 22:17:09 UTC
Permalink
Thank you all for your help. I have a table built now out of primitives
(I grabbed the code for drawing rules from tblf) where you can say
something like

@MyTbl {
@Row named1 { foo } named2 { foo }
/rowpadding @Row named1 { bar } named2 { baz }
}

and you get the header row and a bunch of defaults that I set, for free.

This whole @MyTbl is passed as a named parameter to my report layout
function, which places it in a @Tbl cell that takes up about half the
page, so none of this is happening with galleys. It all looks perfect -
until you put too many rows in it. Then it blows up horribly.

The report presently has four panes: a header row, a diagram and a table
side-by-side, and comments on the bottom. I think I need to make those
out of primitives with galley targets instead of @Tbl cells, scrap
@MyTbl, and send a @Tbl into one of them; then it can wrap to its
heart's content.

But I still won't get to specify half of the parameters and body of that
@Tbl in my include file, and only the data in the document. Some of what
@Tbl deems content, I deem structure in the context of this report
(i.e., the fact that there's a @Tbl right there, it has this many
columns, it has a row at the top with these titles in bold, and some
rules are drawn), and I'm trying to separate my idea of structure from
my idea of content very strictly, so that the document itself contains
only the data that goes into the report, and the look and arrangement of
that data is entirely up to Lout. Like CSS, but with galleys and
coolness.
-----Original Message-----
Sent: Tuesday, October 07, 2008 5:55 PM
Subject: Re: table rows in a galley
But when I make a galley inside the table, things I send to
the galley don't have access to the scope of the table: for
Even worse (if I understand what you are trying to do correctly),
every galley has a single column mark, and so you can't pass a
table row, which has several column marks, through a galley;
or rather, you can, but what comes out the other end has a
single column mark and will be treated as a single column.
I have a vague feeling that you are not splitting responsibilities
between the generating program and lout quite right and that makes
you write lout code that is more complex than necessary.
I agree with his comment. If you are generating the Lout source with
a program then you probably don't need a layer of your own definitions
at all; just go ahead and generate the tables you need.
Definitions with parameters are much easier to work with than galleys,
and they are often the best way to separate format from content. Make
a definition with one parameter for each distinct element of content,
and a body containing all the layout. When the content is an
arbitrary
number of table rows and columns, you have to do something to indicate
within the content where the column and row breaks are. Here is an
right body
{
Winter | Spring | Summer | Autumn
/
body
}
and then you can write
@Seasons
{
Skiing | Floods | Droughts | More droughts
/
Cold | Wet | Hot | Less hot
}
which would make a table with four columns and three rows. The
value of "body" can have any number of column and row marks, and
these will be merged correctly with column and row marks at the
Jeff
Jeff Kingston
2008-10-10 08:44:16 UTC
Permalink
I'm trying to separate my idea of structure from my idea of content
very strictly, so that the document itself contains only the data
that goes into the report, and the look and arrangement of that
data is entirely up to Lout.
It's easy to come to grief when trying to separate content and
format. We're all told that this is a good thing to do, but we
are not told which is which, except in useless platitudes.

You seem to have the definition I prefer implicit in the above:
format is what is common to several documents or several parts
of one document; content is what differs from one to another.
Separating out the format then has a practical purpose: it
makes those common parts uniform, and allows them to change
uniformly if a change in format is decided upon.

This definition has some awkward consequences, however. If
there is just one table heading, then it is content; if the
same table heading occurs in several documents, or in several
places in one document, then it's format. There are probably
plenty of people who would disagree with this.

Jeff

ps If you send a galley into a table cell, that table cell
will probably grab as much horizontal space as possible,
leaving almost nothing for neighbouring cells. You can
get around this by making the table cells fixed width,
using either their width options or the @Wide symbol.
I'm still not convinced that it is a useful thing to do.

Loading...