Working with tags
[1/4] from: gedb01::yahoo::co::uk at: 11-Nov-2003 1:02
I'm just having a little bit of trouble with tags, and
I can't find what I'm after in the docs.
I'm using the following expressions:
fp: []
text: "This is text"
append fp rejoin [<tag> text </tag>]
The result is:
<tagThis is text</tag>>
I wanted:
<tag>This is text</tag>
If I try:
append fp [<tag> text </tag>]
I get:
<tag> text </tag>
If I try:
append fp reduce [<tag> text </tag>]
I get:
<tag> "This is text" </tag>
Which is oh so close, but I don't want them quotes in!
To infuriate me further print [<tag> text </tag>]
displays the desired results.
Where am I going wrong?
What expression should I be using?
[2/4] from: brett:codeconscious at: 11-Nov-2003 12:28
An oldie but a goodie :-)
A Tag! is a type of String! just written differently.
Ie instead of "tag" you write <tag>
Rejoin uses Append
See what happens when you append to a tag:
>> append <body> { bgcolor="green"}
== <body bgcolor="green">
That's they "why" of it.
The how of it...What you wanted was a string result. One approach:
text: "This is text"
reform [<tag> text <tag>]
Another (different result):
rejoin [{} <tag> text <tag>]
The second one works because the second, third and fourth items in the block
are appended to the string giving the right datatype. Compare with:
rejoin [[] <tag> text <tag>]
...which you wouldn't use (reduce would be simpler).
Regards,
Brett.
[3/4] from: tomc:darkwing:uoregon at: 10-Nov-2003 17:30
On Tue, 11 Nov 2003, [iso-8859-1] Ged Byrne wrote:
> I'm just having a little bit of trouble with tags, and
> I can't find what I'm after in the docs.
<<quoted lines omitted: 19>>
> Where am I going wrong?
> What expression should I be using?
a hackerish solution is
fp: copy []
text: "This is text"
insert tail fp rejoin["" <tag> text </tag>]
but that should only be used till a correct solution is given
join assumes the resulting type is the same as the first type.
when the first type is a tag! it tries to make the whole block a tag
... badly
by putting an empty string first, join just builds a string
[4/4] from: gedb01:y:ahoo at: 11-Nov-2003 9:54
Thats great, thanks to all.
--- Tom Conlin <[tomc--darkwing--uoregon--edu]> wrote: >
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted