I'm trying to enhance a script to do the following things.
1). detect the first four words of a paragraph and stylize them
(already does that)
2). Capitalize and stylize the first letter of each paragraph (already
does that via style sheet)
3). Count the number of paragraphs (or number of "vbcrlf & vbcrfl") so
I can insert a images in specific places (i.e. I want to dynamically
insert image 1 in paragraph 1, image 2 into para 2, etc.)
This third item I can't figure out. I've tried it a few ways but keep
running to problems.
Thanks!!!
The following script was provided by Mike Brind, thanks Mike. It
currently can produce results for the first 2 items I listed above but
not exactly the way I want it to. It places an image into the first
paragraph for each "record" but that's not what I want.
Dim str, i, spacepos, word
for wank = 1 to 7
if rsForums.EOF then exit for
if wank = 1 then
response.write "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'>"
End if
if wank = 2 then
response.write "<img id='picFloat' src='me.jpg'
class='picBorderThin'>"
End if
Response.Write "<p><span id='firstWords'>"
storyFix = replace(rsForums("T_MESSAGE"),vbcrlf & vbcrlf, "<p>")
story = replace(storyFix,"<p>", "</p>" & vbcrlf & "<p>")
for i = 1 to 4
spacepos = instr(story," " )
word = left(story,spacepos)
story = right(story,len(story)-spacepos)
response.write word
next
Response.Write "</span>"
Response.Write story
Response.Write "</p>" & vbcrlf & vbcrlf & "<hr>"
rsForums.MoveNext
next
rsForums.Close
Set rsForums = nothing 19 1455
"the other john" wrote...
for wank = 1 to 7
next
Talk about stamina!!!
:oD
Rob
;-)
Rob Meade wrote:
"the other john" wrote...
for wank = 1 to 7
next
Talk about stamina!!!
:oD
Rob
the other john wrote:
I'm trying to enhance a script to do the following things.
1). detect the first four words of a paragraph and stylize them
(already does that)
2). Capitalize and stylize the first letter of each paragraph (already
does that via style sheet)
3). Count the number of paragraphs (or number of "vbcrlf & vbcrfl") so
I can insert a images in specific places (i.e. I want to dynamically
insert image 1 in paragraph 1, image 2 into para 2, etc.)
This third item I can't figure out. I've tried it a few ways but keep
running to problems.
Thanks!!!
The following script was provided by Mike Brind, thanks Mike. It
currently can produce results for the first 2 items I listed above but
not exactly the way I want it to. It places an image into the first
paragraph for each "record" but that's not what I want.
Dim str, i, spacepos, word
for wank = 1 to 7
if rsForums.EOF then exit for
if wank = 1 then
response.write "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'>"
End if
if wank = 2 then
response.write "<img id='picFloat' src='me.jpg'
class='picBorderThin'>"
End if
Response.Write "<p><span id='firstWords'>"
storyFix = replace(rsForums("T_MESSAGE"),vbcrlf & vbcrlf, "<p>")
story = replace(storyFix,"<p>", "</p>" & vbcrlf & "<p>")
for i = 1 to 4
spacepos = instr(story," " )
word = left(story,spacepos)
story = right(story,len(story)-spacepos)
response.write word
next
Response.Write "</span>"
Response.Write story
Response.Write "</p>" & vbcrlf & vbcrlf & "<hr>"
rsForums.MoveNext
next
rsForums.Close
Set rsForums = nothing
I wouldn't do this like this...
At some stage, each story/article is entered into a database. It's at
that point that I would manipulate it in the way you want. That way,
the operation is only ever performed once for each story, rather than
every time a page is requested.
Anyhoo, you need to break the problem down in the opposite order in
which you have. The first thing you need to do is to break the story
into paragraphs. Whether on input or output, this can be done using
split(). You also need to put you images into an array, so you can get
them by index.
Now that you have an array of paragraphs, and an array of images, it's
easy to loop through from 0 to 6, prepending each paragraph with its
associated image html. Within that loop, you can conduct the operation
to style the first few words. You would create a string containing the
first 7 paragraphs (adding <ptags as needed). Then, if there are any
paragraphs left, you would need to loop through those to style the
first few words, and append them to your string. Then its ready for
input/output.
--
Mike Brind
At some stage, each story/article is entered into a database. It's at
that point that I would manipulate it in the way you want. That way,
the operation is only ever performed once for each story,
Good idea.....
Until the customer decides that they want the first 5 words stylized.
Bob Lehmann
"Mike Brind" <pa*******@hotmail.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
>
the other john wrote:
I'm trying to enhance a script to do the following things.
1). detect the first four words of a paragraph and stylize them
(already does that)
2). Capitalize and stylize the first letter of each paragraph (already
does that via style sheet)
3). Count the number of paragraphs (or number of "vbcrlf & vbcrfl") so
I can insert a images in specific places (i.e. I want to dynamically
insert image 1 in paragraph 1, image 2 into para 2, etc.)
This third item I can't figure out. I've tried it a few ways but keep
running to problems.
Thanks!!!
The following script was provided by Mike Brind, thanks Mike. It
currently can produce results for the first 2 items I listed above but
not exactly the way I want it to. It places an image into the first
paragraph for each "record" but that's not what I want.
Dim str, i, spacepos, word
for wank = 1 to 7
if rsForums.EOF then exit for
if wank = 1 then
response.write "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'>"
End if
if wank = 2 then
response.write "<img id='picFloat' src='me.jpg'
class='picBorderThin'>"
End if
Response.Write "<p><span id='firstWords'>"
storyFix = replace(rsForums("T_MESSAGE"),vbcrlf & vbcrlf, "<p>")
story = replace(storyFix,"<p>", "</p>" & vbcrlf & "<p>")
for i = 1 to 4
spacepos = instr(story," " )
word = left(story,spacepos)
story = right(story,len(story)-spacepos)
response.write word
next
Response.Write "</span>"
Response.Write story
Response.Write "</p>" & vbcrlf & vbcrlf & "<hr>"
rsForums.MoveNext
next
rsForums.Close
Set rsForums = nothing
I wouldn't do this like this...
At some stage, each story/article is entered into a database. It's at
that point that I would manipulate it in the way you want. That way,
the operation is only ever performed once for each story, rather than
every time a page is requested.
Anyhoo, you need to break the problem down in the opposite order in
which you have. The first thing you need to do is to break the story
into paragraphs. Whether on input or output, this can be done using
split(). You also need to put you images into an array, so you can get
them by index.
Now that you have an array of paragraphs, and an array of images, it's
easy to loop through from 0 to 6, prepending each paragraph with its
associated image html. Within that loop, you can conduct the operation
to style the first few words. You would create a string containing the
first 7 paragraphs (adding <ptags as needed). Then, if there are any
paragraphs left, you would need to loop through those to style the
first few words, and append them to your string. Then its ready for
input/output.
--
Mike Brind
Even more reason to perform the operation on input. When the customer
changes the brief to have more or less words stylized, I'll look
forward to presenting the budget cost of doing so on existing data :-)
--
Mike Brind
Bob Lehmann wrote:
At some stage, each story/article is entered into a database. It's at
that point that I would manipulate it in the way you want. That way,
the operation is only ever performed once for each story,
Good idea.....
Until the customer decides that they want the first 5 words stylized.
Bob Lehmann
"Mike Brind" <pa*******@hotmail.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
the other john wrote:
I'm trying to enhance a script to do the following things.
>
1). detect the first four words of a paragraph and stylize them
(already does that)
2). Capitalize and stylize the first letter of each paragraph (already
does that via style sheet)
3). Count the number of paragraphs (or number of "vbcrlf & vbcrfl") so
I can insert a images in specific places (i.e. I want to dynamically
insert image 1 in paragraph 1, image 2 into para 2, etc.)
>
This third item I can't figure out. I've tried it a few ways but keep
running to problems.
>
Thanks!!!
>
The following script was provided by Mike Brind, thanks Mike. It
currently can produce results for the first 2 items I listed above but
not exactly the way I want it to. It places an image into the first
paragraph for each "record" but that's not what I want.
>
Dim str, i, spacepos, word
for wank = 1 to 7
if rsForums.EOF then exit for
if wank = 1 then
response.write "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'>"
End if
if wank = 2 then
response.write "<img id='picFloat' src='me.jpg'
class='picBorderThin'>"
End if
Response.Write "<p><span id='firstWords'>"
storyFix = replace(rsForums("T_MESSAGE"),vbcrlf & vbcrlf, "<p>")
story = replace(storyFix,"<p>", "</p>" & vbcrlf & "<p>")
for i = 1 to 4
spacepos = instr(story," " )
word = left(story,spacepos)
story = right(story,len(story)-spacepos)
response.write word
next
>
Response.Write "</span>"
Response.Write story
Response.Write "</p>" & vbcrlf & vbcrlf & "<hr>"
rsForums.MoveNext
next
rsForums.Close
Set rsForums = nothing
I wouldn't do this like this...
At some stage, each story/article is entered into a database. It's at
that point that I would manipulate it in the way you want. That way,
the operation is only ever performed once for each story, rather than
every time a page is requested.
Anyhoo, you need to break the problem down in the opposite order in
which you have. The first thing you need to do is to break the story
into paragraphs. Whether on input or output, this can be done using
split(). You also need to put you images into an array, so you can get
them by index.
Now that you have an array of paragraphs, and an array of images, it's
easy to loop through from 0 to 6, prepending each paragraph with its
associated image html. Within that loop, you can conduct the operation
to style the first few words. You would create a string containing the
first 7 paragraphs (adding <ptags as needed). Then, if there are any
paragraphs left, you would need to loop through those to style the
first few words, and append them to your string. Then its ready for
input/output.
--
Mike Brind
will split() take this?
para = vbcrlf & vbcrlf
Split(mystring, para)
Mike Brind wrote:
Even more reason to perform the operation on input. When the customer
changes the brief to have more or less words stylized, I'll look
forward to presenting the budget cost of doing so on existing data :-)
--
Mike Brind
Bob Lehmann wrote:
At some stage, each story/article is entered into a database. It's at
that point that I would manipulate it in the way you want. That way,
the operation is only ever performed once for each story,
Good idea.....
Until the customer decides that they want the first 5 words stylized.
Bob Lehmann
"Mike Brind" <pa*******@hotmail.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
>
the other john wrote:
I'm trying to enhance a script to do the following things.
1). detect the first four words of a paragraph and stylize them
(already does that)
2). Capitalize and stylize the first letter of each paragraph (already
does that via style sheet)
3). Count the number of paragraphs (or number of "vbcrlf & vbcrfl") so
I can insert a images in specific places (i.e. I want to dynamically
insert image 1 in paragraph 1, image 2 into para 2, etc.)
This third item I can't figure out. I've tried it a few ways but keep
running to problems.
Thanks!!!
The following script was provided by Mike Brind, thanks Mike. It
currently can produce results for the first 2 items I listed above but
not exactly the way I want it to. It places an image into the first
paragraph for each "record" but that's not what I want.
Dim str, i, spacepos, word
for wank = 1 to 7
if rsForums.EOF then exit for
if wank = 1 then
response.write "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'>"
End if
if wank = 2 then
response.write "<img id='picFloat' src='me.jpg'
class='picBorderThin'>"
End if
Response.Write "<p><span id='firstWords'>"
storyFix = replace(rsForums("T_MESSAGE"),vbcrlf & vbcrlf, "<p>")
story = replace(storyFix,"<p>", "</p>" & vbcrlf & "<p>")
for i = 1 to 4
spacepos = instr(story," " )
word = left(story,spacepos)
story = right(story,len(story)-spacepos)
response.write word
next
Response.Write "</span>"
Response.Write story
Response.Write "</p>" & vbcrlf & vbcrlf & "<hr>"
rsForums.MoveNext
next
rsForums.Close
Set rsForums = nothing
>
I wouldn't do this like this...
>
At some stage, each story/article is entered into a database. It's at
that point that I would manipulate it in the way you want. That way,
the operation is only ever performed once for each story, rather than
every time a page is requested.
>
Anyhoo, you need to break the problem down in the opposite order in
which you have. The first thing you need to do is to break the story
into paragraphs. Whether on input or output, this can be done using
split(). You also need to put you images into an array, so you can get
them by index.
>
Now that you have an array of paragraphs, and an array of images, it's
easy to loop through from 0 to 6, prepending each paragraph with its
associated image html. Within that loop, you can conduct the operation
to style the first few words. You would create a string containing the
first 7 paragraphs (adding <ptags as needed). Then, if there are any
paragraphs left, you would need to loop through those to style the
first few words, and append them to your string. Then its ready for
input/output.
>
--
Mike Brind
>
Nope.
paras = split(mystring,vbcrlf & vbcrlf)
This returns a one-dimensional zero-based array of paragraphs, so the
first paragraph will be held in the element referenced as paras(0), the
second in paras(1) etc.
Response.Write Ubound(paras) + 1 will give you the total number of
paragraphs.
--
Mike Brind
the other john wrote:
will split() take this?
para = vbcrlf & vbcrlf
Split(mystring, para)
Mike Brind wrote:
Even more reason to perform the operation on input. When the customer
changes the brief to have more or less words stylized, I'll look
forward to presenting the budget cost of doing so on existing data :-)
--
Mike Brind
Bob Lehmann wrote:
At some stage, each story/article is entered into a database. It's at
that point that I would manipulate it in the way you want. That way,
the operation is only ever performed once for each story,
>
Good idea.....
>
Until the customer decides that they want the first 5 words stylized.
>
Bob Lehmann
>
>
"Mike Brind" <pa*******@hotmail.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
the other john wrote:
I'm trying to enhance a script to do the following things.
>
1). detect the first four words of a paragraph and stylize them
(already does that)
2). Capitalize and stylize the first letter of each paragraph (already
does that via style sheet)
3). Count the number of paragraphs (or number of "vbcrlf & vbcrfl") so
I can insert a images in specific places (i.e. I want to dynamically
insert image 1 in paragraph 1, image 2 into para 2, etc.)
>
This third item I can't figure out. I've tried it a few ways but keep
running to problems.
>
Thanks!!!
>
The following script was provided by Mike Brind, thanks Mike. It
currently can produce results for the first 2 items I listed above but
not exactly the way I want it to. It places an image into the first
paragraph for each "record" but that's not what I want.
>
Dim str, i, spacepos, word
for wank = 1 to 7
if rsForums.EOF then exit for
if wank = 1 then
response.write "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'>"
End if
if wank = 2 then
response.write "<img id='picFloat' src='me.jpg'
class='picBorderThin'>"
End if
Response.Write "<p><span id='firstWords'>"
storyFix = replace(rsForums("T_MESSAGE"),vbcrlf & vbcrlf, "<p>")
story = replace(storyFix,"<p>", "</p>" & vbcrlf & "<p>")
for i = 1 to 4
spacepos = instr(story," " )
word = left(story,spacepos)
story = right(story,len(story)-spacepos)
response.write word
next
>
Response.Write "</span>"
Response.Write story
Response.Write "</p>" & vbcrlf & vbcrlf & "<hr>"
rsForums.MoveNext
next
rsForums.Close
Set rsForums = nothing
I wouldn't do this like this...
At some stage, each story/article is entered into a database. It's at
that point that I would manipulate it in the way you want. That way,
the operation is only ever performed once for each story, rather than
every time a page is requested.
Anyhoo, you need to break the problem down in the opposite order in
which you have. The first thing you need to do is to break the story
into paragraphs. Whether on input or output, this can be done using
split(). You also need to put you images into an array, so you can get
them by index.
Now that you have an array of paragraphs, and an array of images, it's
easy to loop through from 0 to 6, prepending each paragraph with its
associated image html. Within that loop, you can conduct the operation
to style the first few words. You would create a string containing the
first 7 paragraphs (adding <ptags as needed). Then, if there are any
paragraphs left, you would need to loop through those to style the
first few words, and append them to your string. Then its ready for
input/output.
--
Mike Brind
I tried this and it seemed to work except now I have a style issue. The
problem is if the letter I want to be affected by p:first-letter isn't
actually at the beginning of the item it won't work and if I want the
first pic to appear at the top it has to be at the beginning of the
item. Ideas?
Thanks!!!
<style>
#picFloat {float:left;}
p:first-letter {color: #8B0000; font-size:
40px;font-family:times;float:left;}
#firstWords
{text-transform:uppercase;font-family:times;font-size:120%;}
</style>
'
'
myStory = rsForums("T_MESSAGE")
para = vbcrlf & vbcrlf
storyArray = Split(myStory, para)
storyArray(0) = "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'>" & storyArray(0)
storyArray(1) = storyArray(1) & "<img id='picFloat' src='me.jpg'
class='picBorderThin'>"
for each item in storyArray
Response.write "<p>" & item & "</p>"
Next
Mike Brind wrote:
Nope.
paras = split(mystring,vbcrlf & vbcrlf)
This returns a one-dimensional zero-based array of paragraphs, so the
first paragraph will be held in the element referenced as paras(0), the
second in paras(1) etc.
Response.Write Ubound(paras) + 1 will give you the total number of
paragraphs.
--
Mike Brind
the other john wrote:
will split() take this?
para = vbcrlf & vbcrlf
Split(mystring, para)
Mike Brind wrote:
Even more reason to perform the operation on input. When the customer
changes the brief to have more or less words stylized, I'll look
forward to presenting the budget cost of doing so on existing data :-)
>
--
Mike Brind
>
Bob Lehmann wrote:
At some stage, each story/article is entered into a database. It's at
that point that I would manipulate it in the way you want. That way,
the operation is only ever performed once for each story,
Good idea.....
Until the customer decides that they want the first 5 words stylized.
Bob Lehmann
"Mike Brind" <pa*******@hotmail.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
>
the other john wrote:
I'm trying to enhance a script to do the following things.
1). detect the first four words of a paragraph and stylize them
(already does that)
2). Capitalize and stylize the first letter of each paragraph (already
does that via style sheet)
3). Count the number of paragraphs (or number of "vbcrlf & vbcrfl") so
I can insert a images in specific places (i.e. I want to dynamically
insert image 1 in paragraph 1, image 2 into para 2, etc.)
This third item I can't figure out. I've tried it a few ways but keep
running to problems.
Thanks!!!
The following script was provided by Mike Brind, thanks Mike. It
currently can produce results for the first 2 items I listed above but
not exactly the way I want it to. It places an image into the first
paragraph for each "record" but that's not what I want.
Dim str, i, spacepos, word
for wank = 1 to 7
if rsForums.EOF then exit for
if wank = 1 then
response.write "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'>"
End if
if wank = 2 then
response.write "<img id='picFloat' src='me.jpg'
class='picBorderThin'>"
End if
Response.Write "<p><span id='firstWords'>"
storyFix = replace(rsForums("T_MESSAGE"),vbcrlf & vbcrlf, "<p>")
story = replace(storyFix,"<p>", "</p>" & vbcrlf & "<p>")
for i = 1 to 4
spacepos = instr(story," " )
word = left(story,spacepos)
story = right(story,len(story)-spacepos)
response.write word
next
Response.Write "</span>"
Response.Write story
Response.Write "</p>" & vbcrlf & vbcrlf & "<hr>"
rsForums.MoveNext
next
rsForums.Close
Set rsForums = nothing
>
I wouldn't do this like this...
>
At some stage, each story/article is entered into a database. It's at
that point that I would manipulate it in the way you want. That way,
the operation is only ever performed once for each story, rather than
every time a page is requested.
>
Anyhoo, you need to break the problem down in the opposite order in
which you have. The first thing you need to do is to break the story
into paragraphs. Whether on input or output, this can be done using
split(). You also need to put you images into an array, so you can get
them by index.
>
Now that you have an array of paragraphs, and an array of images, it's
easy to loop through from 0 to 6, prepending each paragraph with its
associated image html. Within that loop, you can conduct the operation
to style the first few words. You would create a string containing the
first 7 paragraphs (adding <ptags as needed). Then, if there are any
paragraphs left, you would need to loop through those to style the
first few words, and append them to your string. Then its ready for
input/output.
>
--
Mike Brind
>
I'm no CSS expert, so you might be better off asking this in a style
sheet group. However, try putting the text in a <ptag
storyArray(0) = "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'><p>" & storyArray(0) & "</p>"
--
Mike Brind
the other john wrote:
I tried this and it seemed to work except now I have a style issue. The
problem is if the letter I want to be affected by p:first-letter isn't
actually at the beginning of the item it won't work and if I want the
first pic to appear at the top it has to be at the beginning of the
item. Ideas?
Thanks!!!
<style>
#picFloat {float:left;}
p:first-letter {color: #8B0000; font-size:
40px;font-family:times;float:left;}
#firstWords
{text-transform:uppercase;font-family:times;font-size:120%;}
</style>
'
'
myStory = rsForums("T_MESSAGE")
para = vbcrlf & vbcrlf
storyArray = Split(myStory, para)
storyArray(0) = "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'>" & storyArray(0)
storyArray(1) = storyArray(1) & "<img id='picFloat' src='me.jpg'
class='picBorderThin'>"
for each item in storyArray
Response.write "<p>" & item & "</p>"
Next
Mike Brind wrote:
Nope.
paras = split(mystring,vbcrlf & vbcrlf)
This returns a one-dimensional zero-based array of paragraphs, so the
first paragraph will be held in the element referenced as paras(0), the
second in paras(1) etc.
Response.Write Ubound(paras) + 1 will give you the total number of
paragraphs.
--
Mike Brind
the other john wrote:
will split() take this?
>
para = vbcrlf & vbcrlf
Split(mystring, para)
>
>
Mike Brind wrote:
Even more reason to perform the operation on input. When the customer
changes the brief to have more or less words stylized, I'll look
forward to presenting the budget cost of doing so on existing data :-)
--
Mike Brind
Bob Lehmann wrote:
At some stage, each story/article is entered into a database. It's at
that point that I would manipulate it in the way you want. That way,
the operation is only ever performed once for each story,
>
Good idea.....
>
Until the customer decides that they want the first 5 words stylized.
>
Bob Lehmann
>
>
"Mike Brind" <pa*******@hotmail.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
the other john wrote:
I'm trying to enhance a script to do the following things.
>
1). detect the first four words of a paragraph and stylize them
(already does that)
2). Capitalize and stylize the first letter of each paragraph (already
does that via style sheet)
3). Count the number of paragraphs (or number of "vbcrlf & vbcrfl") so
I can insert a images in specific places (i.e. I want to dynamically
insert image 1 in paragraph 1, image 2 into para 2, etc.)
>
This third item I can't figure out. I've tried it a few ways but keep
running to problems.
>
Thanks!!!
>
The following script was provided by Mike Brind, thanks Mike. It
currently can produce results for the first 2 items I listed above but
not exactly the way I want it to. It places an image into the first
paragraph for each "record" but that's not what I want.
>
Dim str, i, spacepos, word
for wank = 1 to 7
if rsForums.EOF then exit for
if wank = 1 then
response.write "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'>"
End if
if wank = 2 then
response.write "<img id='picFloat' src='me.jpg'
class='picBorderThin'>"
End if
Response.Write "<p><span id='firstWords'>"
storyFix = replace(rsForums("T_MESSAGE"),vbcrlf & vbcrlf, "<p>")
story = replace(storyFix,"<p>", "</p>" & vbcrlf & "<p>")
for i = 1 to 4
spacepos = instr(story," " )
word = left(story,spacepos)
story = right(story,len(story)-spacepos)
response.write word
next
>
Response.Write "</span>"
Response.Write story
Response.Write "</p>" & vbcrlf & vbcrlf & "<hr>"
rsForums.MoveNext
next
rsForums.Close
Set rsForums = nothing
I wouldn't do this like this...
At some stage, each story/article is entered into a database. It's at
that point that I would manipulate it in the way you want. That way,
the operation is only ever performed once for each story, rather than
every time a page is requested.
Anyhoo, you need to break the problem down in the opposite order in
which you have. The first thing you need to do is to break the story
into paragraphs. Whether on input or output, this can be done using
split(). You also need to put you images into an array, so you can get
them by index.
Now that you have an array of paragraphs, and an array of images, it's
easy to loop through from 0 to 6, prepending each paragraph with its
associated image html. Within that loop, you can conduct the operation
to style the first few words. You would create a string containing the
first 7 paragraphs (adding <ptags as needed). Then, if there are any
paragraphs left, you would need to loop through those to style the
first few words, and append them to your string. Then its ready for
input/output.
--
Mike Brind
Cool, this almost has it. But to make it even better is there a way
other than the For Each loop that I can use to access "part" of the
array? If I could just stylize specific parts of the array one way and
the rest just be other, like an if else sort of thing that would put
this thing to bed. The array works "great"....not I just need to
figure out how to work with just "parts" of it. I'm thinking the For
Each loop isn't going to work in this case since it's an all or nothing
sort of thing. I haven't worked with arrays that much and don't know
the possibilities.
Thanks Mike! Learning a lot here!!
Mike Brind wrote:
I'm no CSS expert, so you might be better off asking this in a style
sheet group. However, try putting the text in a <ptag
storyArray(0) = "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'><p>" & storyArray(0) & "</p>"
--
Mike Brind
the other john wrote:
I tried this and it seemed to work except now I have a style issue. The
problem is if the letter I want to be affected by p:first-letter isn't
actually at the beginning of the item it won't work and if I want the
first pic to appear at the top it has to be at the beginning of the
item. Ideas?
Thanks!!!
<style>
#picFloat {float:left;}
p:first-letter {color: #8B0000; font-size:
40px;font-family:times;float:left;}
#firstWords
{text-transform:uppercase;font-family:times;font-size:120%;}
</style>
'
'
myStory = rsForums("T_MESSAGE")
para = vbcrlf & vbcrlf
storyArray = Split(myStory, para)
storyArray(0) = "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'>" & storyArray(0)
storyArray(1) = storyArray(1) & "<img id='picFloat' src='me.jpg'
class='picBorderThin'>"
for each item in storyArray
Response.write "<p>" & item & "</p>"
Next
Mike Brind wrote:
Nope.
>
paras = split(mystring,vbcrlf & vbcrlf)
>
This returns a one-dimensional zero-based array of paragraphs, so the
first paragraph will be held in the element referenced as paras(0), the
second in paras(1) etc.
>
Response.Write Ubound(paras) + 1 will give you the total number of
paragraphs.
>
--
Mike Brind
>
the other john wrote:
will split() take this?
para = vbcrlf & vbcrlf
Split(mystring, para)
Mike Brind wrote:
Even more reason to perform the operation on input. When the customer
changes the brief to have more or less words stylized, I'll look
forward to presenting the budget cost of doing so on existing data :-)
>
--
Mike Brind
>
Bob Lehmann wrote:
At some stage, each story/article is entered into a database. It's at
that point that I would manipulate it in the way you want. That way,
the operation is only ever performed once for each story,
Good idea.....
Until the customer decides that they want the first 5 words stylized.
Bob Lehmann
"Mike Brind" <pa*******@hotmail.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
>
the other john wrote:
I'm trying to enhance a script to do the following things.
1). detect the first four words of a paragraph and stylize them
(already does that)
2). Capitalize and stylize the first letter of each paragraph (already
does that via style sheet)
3). Count the number of paragraphs (or number of "vbcrlf & vbcrfl") so
I can insert a images in specific places (i.e. I want to dynamically
insert image 1 in paragraph 1, image 2 into para 2, etc.)
This third item I can't figure out. I've tried it a few ways but keep
running to problems.
Thanks!!!
The following script was provided by Mike Brind, thanks Mike. It
currently can produce results for the first 2 items I listed above but
not exactly the way I want it to. It places an image into the first
paragraph for each "record" but that's not what I want.
Dim str, i, spacepos, word
for wank = 1 to 7
if rsForums.EOF then exit for
if wank = 1 then
response.write "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'>"
End if
if wank = 2 then
response.write "<img id='picFloat' src='me.jpg'
class='picBorderThin'>"
End if
Response.Write "<p><span id='firstWords'>"
storyFix = replace(rsForums("T_MESSAGE"),vbcrlf & vbcrlf, "<p>")
story = replace(storyFix,"<p>", "</p>" & vbcrlf & "<p>")
for i = 1 to 4
spacepos = instr(story," " )
word = left(story,spacepos)
story = right(story,len(story)-spacepos)
response.write word
next
Response.Write "</span>"
Response.Write story
Response.Write "</p>" & vbcrlf & vbcrlf & "<hr>"
rsForums.MoveNext
next
rsForums.Close
Set rsForums = nothing
>
I wouldn't do this like this...
>
At some stage, each story/article is entered into a database. It's at
that point that I would manipulate it in the way you want. That way,
the operation is only ever performed once for each story, rather than
every time a page is requested.
>
Anyhoo, you need to break the problem down in the opposite order in
which you have. The first thing you need to do is to break the story
into paragraphs. Whether on input or output, this can be done using
split(). You also need to put you images into an array, so you can get
them by index.
>
Now that you have an array of paragraphs, and an array of images, it's
easy to loop through from 0 to 6, prepending each paragraph with its
associated image html. Within that loop, you can conduct the operation
to style the first few words. You would create a string containing the
first 7 paragraphs (adding <ptags as needed). Then, if there are any
paragraphs left, you would need to loop through those to style the
first few words, and append them to your string. Then its ready for
input/output.
>
--
Mike Brind
>
Tried this and it only delivers one word and appears to exit the loop.
In other words it appears to stylize the first word rather than the
desired first 4. Any ideas?
myStory = rsForums("T_MESSAGE")
para = vbcrlf & vbcrlf
storyArray = Split(myStory, para)
for i = 1 to 4
spacepos = instr(storyArray(0)," " )
word = left(storyArray(0),spacepos)
story = right(storyArray(0),len(storyArray(0))-spacepos)
next
storyArray(0) = "<span id='firstWords'>" & word & "</span>" & story
Thanks again!!!
the other john wrote:
Cool, this almost has it. But to make it even better is there a way
other than the For Each loop that I can use to access "part" of the
array? If I could just stylize specific parts of the array one way and
the rest just be other, like an if else sort of thing that would put
this thing to bed. The array works "great"....not I just need to
figure out how to work with just "parts" of it. I'm thinking the For
Each loop isn't going to work in this case since it's an all or nothing
sort of thing. I haven't worked with arrays that much and don't know
the possibilities.
Thanks Mike! Learning a lot here!!
Mike Brind wrote:
I'm no CSS expert, so you might be better off asking this in a style
sheet group. However, try putting the text in a <ptag
storyArray(0) = "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'><p>" & storyArray(0) & "</p>"
--
Mike Brind
the other john wrote:
I tried this and it seemed to work except now I have a style issue. The
problem is if the letter I want to be affected by p:first-letter isn't
actually at the beginning of the item it won't work and if I want the
first pic to appear at the top it has to be at the beginning of the
item. Ideas?
>
Thanks!!!
>
<style>
#picFloat {float:left;}
p:first-letter {color: #8B0000; font-size:
40px;font-family:times;float:left;}
#firstWords
{text-transform:uppercase;font-family:times;font-size:120%;}
</style>
'
'
myStory = rsForums("T_MESSAGE")
>
para = vbcrlf & vbcrlf
>
storyArray = Split(myStory, para)
storyArray(0) = "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'>" & storyArray(0)
storyArray(1) = storyArray(1) & "<img id='picFloat' src='me.jpg'
class='picBorderThin'>"
>
for each item in storyArray
Response.write "<p>" & item & "</p>"
Next
>
>
Mike Brind wrote:
Nope.
paras = split(mystring,vbcrlf & vbcrlf)
This returns a one-dimensional zero-based array of paragraphs, so the
first paragraph will be held in the element referenced as paras(0), the
second in paras(1) etc.
Response.Write Ubound(paras) + 1 will give you the total number of
paragraphs.
--
Mike Brind
the other john wrote:
will split() take this?
>
para = vbcrlf & vbcrlf
Split(mystring, para)
>
>
Mike Brind wrote:
Even more reason to perform the operation on input. When the customer
changes the brief to have more or less words stylized, I'll look
forward to presenting the budget cost of doing so on existing data :-)
--
Mike Brind
Bob Lehmann wrote:
At some stage, each story/article is entered into a database. It's at
that point that I would manipulate it in the way you want. That way,
the operation is only ever performed once for each story,
>
Good idea.....
>
Until the customer decides that they want the first 5 words stylized.
>
Bob Lehmann
>
>
"Mike Brind" <pa*******@hotmail.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
the other john wrote:
I'm trying to enhance a script to do the following things.
>
1). detect the first four words of a paragraph and stylize them
(already does that)
2). Capitalize and stylize the first letter of each paragraph (already
does that via style sheet)
3). Count the number of paragraphs (or number of "vbcrlf & vbcrfl") so
I can insert a images in specific places (i.e. I want to dynamically
insert image 1 in paragraph 1, image 2 into para 2, etc.)
>
This third item I can't figure out. I've tried it a few ways but keep
running to problems.
>
Thanks!!!
>
The following script was provided by Mike Brind, thanks Mike. It
currently can produce results for the first 2 items I listed above but
not exactly the way I want it to. It places an image into the first
paragraph for each "record" but that's not what I want.
>
Dim str, i, spacepos, word
for wank = 1 to 7
if rsForums.EOF then exit for
if wank = 1 then
response.write "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'>"
End if
if wank = 2 then
response.write "<img id='picFloat' src='me.jpg'
class='picBorderThin'>"
End if
Response.Write "<p><span id='firstWords'>"
storyFix = replace(rsForums("T_MESSAGE"),vbcrlf & vbcrlf, "<p>")
story = replace(storyFix,"<p>", "</p>" & vbcrlf & "<p>")
for i = 1 to 4
spacepos = instr(story," " )
word = left(story,spacepos)
story = right(story,len(story)-spacepos)
response.write word
next
>
Response.Write "</span>"
Response.Write story
Response.Write "</p>" & vbcrlf & vbcrlf & "<hr>"
rsForums.MoveNext
next
rsForums.Close
Set rsForums = nothing
I wouldn't do this like this...
At some stage, each story/article is entered into a database. It's at
that point that I would manipulate it in the way you want. That way,
the operation is only ever performed once for each story, rather than
every time a page is requested.
Anyhoo, you need to break the problem down in the opposite order in
which you have. The first thing you need to do is to break the story
into paragraphs. Whether on input or output, this can be done using
split(). You also need to put you images into an array, so you can get
them by index.
Now that you have an array of paragraphs, and an array of images, it's
easy to loop through from 0 to 6, prepending each paragraph with its
associated image html. Within that loop, you can conduct the operation
to style the first few words. You would create a string containing the
first 7 paragraphs (adding <ptags as needed). Then, if there are any
paragraphs left, you would need to loop through those to style the
first few words, and append them to your string. Then its ready for
input/output.
--
Mike Brind
myStory = rsForums("T_MESSAGE")
paras = Split(myStory, vbcrlf & vbcrlf)
para = paras(0)
Response.Write "<span id='firstWords'>"
for i = 1 to 4
spacepos = instr(para," " )
word = left(para,spacepos)
Response.Write word
para= right(para,len(story)-spacepos)
next
Response.Write "</span>" & para
Each time the loop executes, it strips the first word from the
paragraph after writing it to the browser within the <spantags. The
closing </span tag is written after the loop finishes, with the
remainder of the paragraph after it.
--
Mike Brind
the other john wrote:
Tried this and it only delivers one word and appears to exit the loop.
In other words it appears to stylize the first word rather than the
desired first 4. Any ideas?
myStory = rsForums("T_MESSAGE")
para = vbcrlf & vbcrlf
storyArray = Split(myStory, para)
for i = 1 to 4
spacepos = instr(storyArray(0)," " )
word = left(storyArray(0),spacepos)
story = right(storyArray(0),len(storyArray(0))-spacepos)
next
storyArray(0) = "<span id='firstWords'>" & word & "</span>" & story
Thanks again!!!
the other john wrote:
Cool, this almost has it. But to make it even better is there a way
other than the For Each loop that I can use to access "part" of the
array? If I could just stylize specific parts of the array one way and
the rest just be other, like an if else sort of thing that would put
this thing to bed. The array works "great"....not I just need to
figure out how to work with just "parts" of it. I'm thinking the For
Each loop isn't going to work in this case since it's an all or nothing
sort of thing. I haven't worked with arrays that much and don't know
the possibilities.
Thanks Mike! Learning a lot here!!
Mike Brind wrote:
I'm no CSS expert, so you might be better off asking this in a style
sheet group. However, try putting the text in a <ptag
>
storyArray(0) = "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'><p>" & storyArray(0) & "</p>"
>
--
Mike Brind
>
the other john wrote:
I tried this and it seemed to work except now I have a style issue. The
problem is if the letter I want to be affected by p:first-letter isn't
actually at the beginning of the item it won't work and if I want the
first pic to appear at the top it has to be at the beginning of the
item. Ideas?
Thanks!!!
<style>
#picFloat {float:left;}
p:first-letter {color: #8B0000; font-size:
40px;font-family:times;float:left;}
#firstWords
{text-transform:uppercase;font-family:times;font-size:120%;}
</style>
'
'
myStory = rsForums("T_MESSAGE")
para = vbcrlf & vbcrlf
storyArray = Split(myStory, para)
storyArray(0) = "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'>" & storyArray(0)
storyArray(1) = storyArray(1) & "<img id='picFloat' src='me.jpg'
class='picBorderThin'>"
for each item in storyArray
Response.write "<p>" & item & "</p>"
Next
Mike Brind wrote:
Nope.
>
paras = split(mystring,vbcrlf & vbcrlf)
>
This returns a one-dimensional zero-based array of paragraphs, so the
first paragraph will be held in the element referenced as paras(0), the
second in paras(1) etc.
>
Response.Write Ubound(paras) + 1 will give you the total number of
paragraphs.
>
--
Mike Brind
>
the other john wrote:
will split() take this?
para = vbcrlf & vbcrlf
Split(mystring, para)
Mike Brind wrote:
Even more reason to perform the operation on input. When the customer
changes the brief to have more or less words stylized, I'll look
forward to presenting the budget cost of doing so on existing data :-)
>
--
Mike Brind
>
Bob Lehmann wrote:
At some stage, each story/article is entered into a database. It's at
that point that I would manipulate it in the way you want. That way,
the operation is only ever performed once for each story,
Good idea.....
Until the customer decides that they want the first 5 words stylized.
Bob Lehmann
"Mike Brind" <pa*******@hotmail.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
>
the other john wrote:
I'm trying to enhance a script to do the following things.
1). detect the first four words of a paragraph and stylize them
(already does that)
2). Capitalize and stylize the first letter of each paragraph (already
does that via style sheet)
3). Count the number of paragraphs (or number of "vbcrlf & vbcrfl") so
I can insert a images in specific places (i.e. I want to dynamically
insert image 1 in paragraph 1, image 2 into para 2, etc.)
This third item I can't figure out. I've tried it a few ways but keep
running to problems.
Thanks!!!
The following script was provided by Mike Brind, thanks Mike. It
currently can produce results for the first 2 items I listed above but
not exactly the way I want it to. It places an image into the first
paragraph for each "record" but that's not what I want.
Dim str, i, spacepos, word
for wank = 1 to 7
if rsForums.EOF then exit for
if wank = 1 then
response.write "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'>"
End if
if wank = 2 then
response.write "<img id='picFloat' src='me.jpg'
class='picBorderThin'>"
End if
Response.Write "<p><span id='firstWords'>"
storyFix = replace(rsForums("T_MESSAGE"),vbcrlf & vbcrlf, "<p>")
story = replace(storyFix,"<p>", "</p>" & vbcrlf & "<p>")
for i = 1 to 4
spacepos = instr(story," " )
word = left(story,spacepos)
story = right(story,len(story)-spacepos)
response.write word
next
Response.Write "</span>"
Response.Write story
Response.Write "</p>" & vbcrlf & vbcrlf & "<hr>"
rsForums.MoveNext
next
rsForums.Close
Set rsForums = nothing
>
I wouldn't do this like this...
>
At some stage, each story/article is entered into a database. It's at
that point that I would manipulate it in the way you want. That way,
the operation is only ever performed once for each story, rather than
every time a page is requested.
>
Anyhoo, you need to break the problem down in the opposite order in
which you have. The first thing you need to do is to break the story
into paragraphs. Whether on input or output, this can be done using
split(). You also need to put you images into an array, so you can get
them by index.
>
Now that you have an array of paragraphs, and an array of images, it's
easy to loop through from 0 to 6, prepending each paragraph with its
associated image html. Within that loop, you can conduct the operation
to style the first few words. You would create a string containing the
first 7 paragraphs (adding <ptags as needed). Then, if there are any
paragraphs left, you would need to loop through those to style the
first few words, and append them to your string. Then its ready for
input/output.
>
--
Mike Brind
>
for some reason now I'm getting this...odd...don't know why..
Microsoft VBScript runtime error '800a0005'
Invalid procedure call or argument: 'right'
/paraTest.asp, line 36
"right" didn't cause a problem before. To be clear about what I was
trying to do I should have include the entire script. I'm trying to
tweek array items after getting the first 4 words formatted.
Thanks for your help Mike, I'm so close now, this is awesome!!!
myStory = rsForums("T_MESSAGE")
para = vbcrlf & vbcrlf
storyArray = Split(myStory, para)
for i = 1 to 4
spacepos = instr(storyArray(0)," " )
word = left(storyArray(0),spacepos)
story = right(storyArray(0),len(storyArray(0))-spacepos)
next
storyArray(0) = "<span id='firstWords'>" & word & "</span>" & story
storyArray(0) = "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'><p>" & storyArray(0) & "</p><blockquote>An
importand quote from the story here<blockquote>"
storyArray(1) = storyArray(1) & "<img id='picFloat' src='me.jpg'
class='picBorderThin'>"
for each item in storyArray
Response.write "<p>" & item & "</p>" & vbcrlf
Next
Mike Brind wrote:
myStory = rsForums("T_MESSAGE")
paras = Split(myStory, vbcrlf & vbcrlf)
para = paras(0)
Response.Write "<span id='firstWords'>"
for i = 1 to 4
spacepos = instr(para," " )
word = left(para,spacepos)
Response.Write word
para= right(para,len(story)-spacepos)
next
Response.Write "</span>" & para
Each time the loop executes, it strips the first word from the
paragraph after writing it to the browser within the <spantags. The
closing </span tag is written after the loop finishes, with the
remainder of the paragraph after it.
--
Mike Brind
the other john wrote:
Tried this and it only delivers one word and appears to exit the loop.
In other words it appears to stylize the first word rather than the
desired first 4. Any ideas?
myStory = rsForums("T_MESSAGE")
para = vbcrlf & vbcrlf
storyArray = Split(myStory, para)
for i = 1 to 4
spacepos = instr(storyArray(0)," " )
word = left(storyArray(0),spacepos)
story = right(storyArray(0),len(storyArray(0))-spacepos)
next
storyArray(0) = "<span id='firstWords'>" & word & "</span>" & story
Thanks again!!!
the other john wrote:
Cool, this almost has it. But to make it even better is there a way
other than the For Each loop that I can use to access "part" of the
array? If I could just stylize specific parts of the array one way and
the rest just be other, like an if else sort of thing that would put
this thing to bed. The array works "great"....not I just need to
figure out how to work with just "parts" of it. I'm thinking the For
Each loop isn't going to work in this case since it's an all or nothing
sort of thing. I haven't worked with arrays that much and don't know
the possibilities.
>
Thanks Mike! Learning a lot here!!
>
>
Mike Brind wrote:
I'm no CSS expert, so you might be better off asking this in a style
sheet group. However, try putting the text in a <ptag
storyArray(0) = "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'><p>" & storyArray(0) & "</p>"
--
Mike Brind
the other john wrote:
I tried this and it seemed to work except now I have a style issue. The
problem is if the letter I want to be affected by p:first-letter isn't
actually at the beginning of the item it won't work and if I want the
first pic to appear at the top it has to be at the beginning of the
item. Ideas?
>
Thanks!!!
>
<style>
#picFloat {float:left;}
p:first-letter {color: #8B0000; font-size:
40px;font-family:times;float:left;}
#firstWords
{text-transform:uppercase;font-family:times;font-size:120%;}
</style>
'
'
myStory = rsForums("T_MESSAGE")
>
para = vbcrlf & vbcrlf
>
storyArray = Split(myStory, para)
storyArray(0) = "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'>" & storyArray(0)
storyArray(1) = storyArray(1) & "<img id='picFloat' src='me.jpg'
class='picBorderThin'>"
>
for each item in storyArray
Response.write "<p>" & item & "</p>"
Next
>
>
Mike Brind wrote:
Nope.
paras = split(mystring,vbcrlf & vbcrlf)
This returns a one-dimensional zero-based array of paragraphs, so the
first paragraph will be held in the element referenced as paras(0), the
second in paras(1) etc.
Response.Write Ubound(paras) + 1 will give you the total number of
paragraphs.
--
Mike Brind
the other john wrote:
will split() take this?
>
para = vbcrlf & vbcrlf
Split(mystring, para)
>
>
Mike Brind wrote:
Even more reason to perform the operation on input. When the customer
changes the brief to have more or less words stylized, I'll look
forward to presenting the budget cost of doing so on existing data :-)
--
Mike Brind
Bob Lehmann wrote:
At some stage, each story/article is entered into a database. It's at
that point that I would manipulate it in the way you want. That way,
the operation is only ever performed once for each story,
>
Good idea.....
>
Until the customer decides that they want the first 5 words stylized.
>
Bob Lehmann
>
>
"Mike Brind" <pa*******@hotmail.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
the other john wrote:
I'm trying to enhance a script to do the following things.
>
1). detect the first four words of a paragraph and stylize them
(already does that)
2). Capitalize and stylize the first letter of each paragraph (already
does that via style sheet)
3). Count the number of paragraphs (or number of "vbcrlf & vbcrfl") so
I can insert a images in specific places (i.e. I want to dynamically
insert image 1 in paragraph 1, image 2 into para 2, etc.)
>
This third item I can't figure out. I've tried it a few ways but keep
running to problems.
>
Thanks!!!
>
The following script was provided by Mike Brind, thanks Mike. It
currently can produce results for the first 2 items I listed above but
not exactly the way I want it to. It places an image into the first
paragraph for each "record" but that's not what I want.
>
Dim str, i, spacepos, word
for wank = 1 to 7
if rsForums.EOF then exit for
if wank = 1 then
response.write "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'>"
End if
if wank = 2 then
response.write "<img id='picFloat' src='me.jpg'
class='picBorderThin'>"
End if
Response.Write "<p><span id='firstWords'>"
storyFix = replace(rsForums("T_MESSAGE"),vbcrlf & vbcrlf, "<p>")
story = replace(storyFix,"<p>", "</p>" & vbcrlf & "<p>")
for i = 1 to 4
spacepos = instr(story," " )
word = left(story,spacepos)
story = right(story,len(story)-spacepos)
response.write word
next
>
Response.Write "</span>"
Response.Write story
Response.Write "</p>" & vbcrlf & vbcrlf & "<hr>"
rsForums.MoveNext
next
rsForums.Close
Set rsForums = nothing
I wouldn't do this like this...
At some stage, each story/article is entered into a database. It's at
that point that I would manipulate it in the way you want. That way,
the operation is only ever performed once for each story, rather than
every time a page is requested.
Anyhoo, you need to break the problem down in the opposite order in
which you have. The first thing you need to do is to break the story
into paragraphs. Whether on input or output, this can be done using
split(). You also need to put you images into an array, so you can get
them by index.
Now that you have an array of paragraphs, and an array of images, it's
easy to loop through from 0 to 6, prepending each paragraph with its
associated image html. Within that loop, you can conduct the operation
to style the first few words. You would create a string containing the
first 7 paragraphs (adding <ptags as needed). Then, if there are any
paragraphs left, you would need to loop through those to style the
first few words, and append them to your string. Then its ready for
input/output.
--
Mike Brind
It's not going to work because you are not changing the paragraph on
each loop. You change the variable from storyArray to story, but on
the next iteration, it goes back to storyArray again. At that point,
story is storyArray minus the first word, but when you enter the loop
again, storyArray(0) is still the same value as when you started (ie,
the whole paragraph with all words intact). Try replacing the example
you posted earlier with the bit I just posted, See if that works.
--
Mike Brind
the other john wrote:
for some reason now I'm getting this...odd...don't know why..
Microsoft VBScript runtime error '800a0005'
Invalid procedure call or argument: 'right'
/paraTest.asp, line 36
"right" didn't cause a problem before. To be clear about what I was
trying to do I should have include the entire script. I'm trying to
tweek array items after getting the first 4 words formatted.
Thanks for your help Mike, I'm so close now, this is awesome!!!
myStory = rsForums("T_MESSAGE")
para = vbcrlf & vbcrlf
storyArray = Split(myStory, para)
for i = 1 to 4
spacepos = instr(storyArray(0)," " )
word = left(storyArray(0),spacepos)
story = right(storyArray(0),len(storyArray(0))-spacepos)
next
storyArray(0) = "<span id='firstWords'>" & word & "</span>" & story
storyArray(0) = "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'><p>" & storyArray(0) & "</p><blockquote>An
importand quote from the story here<blockquote>"
storyArray(1) = storyArray(1) & "<img id='picFloat' src='me.jpg'
class='picBorderThin'>"
for each item in storyArray
Response.write "<p>" & item & "</p>" & vbcrlf
Next
Mike Brind wrote:
myStory = rsForums("T_MESSAGE")
paras = Split(myStory, vbcrlf & vbcrlf)
para = paras(0)
Response.Write "<span id='firstWords'>"
for i = 1 to 4
spacepos = instr(para," " )
word = left(para,spacepos)
Response.Write word
para= right(para,len(story)-spacepos)
next
Response.Write "</span>" & para
Each time the loop executes, it strips the first word from the
paragraph after writing it to the browser within the <spantags. The
closing </span tag is written after the loop finishes, with the
remainder of the paragraph after it.
--
Mike Brind
the other john wrote:
Tried this and it only delivers one word and appears to exit the loop.
In other words it appears to stylize the first word rather than the
desired first 4. Any ideas?
>
myStory = rsForums("T_MESSAGE")
>
para = vbcrlf & vbcrlf
>
storyArray = Split(myStory, para)
>
for i = 1 to 4
spacepos = instr(storyArray(0)," " )
word = left(storyArray(0),spacepos)
story = right(storyArray(0),len(storyArray(0))-spacepos)
next
>
storyArray(0) = "<span id='firstWords'>" & word & "</span>" & story
>
>
>
Thanks again!!!
>
>
the other john wrote:
Cool, this almost has it. But to make it even better is there a way
other than the For Each loop that I can use to access "part" of the
array? If I could just stylize specific parts of the array one way and
the rest just be other, like an if else sort of thing that would put
this thing to bed. The array works "great"....not I just need to
figure out how to work with just "parts" of it. I'm thinking the For
Each loop isn't going to work in this case since it's an all or nothing
sort of thing. I haven't worked with arrays that much and don't know
the possibilities.
Thanks Mike! Learning a lot here!!
Mike Brind wrote:
I'm no CSS expert, so you might be better off asking this in a style
sheet group. However, try putting the text in a <ptag
>
storyArray(0) = "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'><p>" & storyArray(0) & "</p>"
>
--
Mike Brind
>
the other john wrote:
I tried this and it seemed to work except now I have a style issue. The
problem is if the letter I want to be affected by p:first-letter isn't
actually at the beginning of the item it won't work and if I want the
first pic to appear at the top it has to be at the beginning of the
item. Ideas?
Thanks!!!
<style>
#picFloat {float:left;}
p:first-letter {color: #8B0000; font-size:
40px;font-family:times;float:left;}
#firstWords
{text-transform:uppercase;font-family:times;font-size:120%;}
</style>
'
'
myStory = rsForums("T_MESSAGE")
para = vbcrlf & vbcrlf
storyArray = Split(myStory, para)
storyArray(0) = "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'>" & storyArray(0)
storyArray(1) = storyArray(1) & "<img id='picFloat' src='me.jpg'
class='picBorderThin'>"
for each item in storyArray
Response.write "<p>" & item & "</p>"
Next
Mike Brind wrote:
Nope.
>
paras = split(mystring,vbcrlf & vbcrlf)
>
This returns a one-dimensional zero-based array of paragraphs, so the
first paragraph will be held in the element referenced as paras(0), the
second in paras(1) etc.
>
Response.Write Ubound(paras) + 1 will give you the total number of
paragraphs.
>
--
Mike Brind
>
the other john wrote:
will split() take this?
para = vbcrlf & vbcrlf
Split(mystring, para)
Mike Brind wrote:
Even more reason to perform the operation on input. When the customer
changes the brief to have more or less words stylized, I'll look
forward to presenting the budget cost of doing so on existing data :-)
>
--
Mike Brind
>
Bob Lehmann wrote:
At some stage, each story/article is entered into a database. It's at
that point that I would manipulate it in the way you want. That way,
the operation is only ever performed once for each story,
Good idea.....
Until the customer decides that they want the first 5 words stylized.
Bob Lehmann
"Mike Brind" <pa*******@hotmail.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
>
the other john wrote:
I'm trying to enhance a script to do the following things.
1). detect the first four words of a paragraph and stylize them
(already does that)
2). Capitalize and stylize the first letter of each paragraph (already
does that via style sheet)
3). Count the number of paragraphs (or number of "vbcrlf & vbcrfl") so
I can insert a images in specific places (i.e. I want to dynamically
insert image 1 in paragraph 1, image 2 into para 2, etc.)
This third item I can't figure out. I've tried it a few ways but keep
running to problems.
Thanks!!!
The following script was provided by Mike Brind, thanks Mike. It
currently can produce results for the first 2 items I listed above but
not exactly the way I want it to. It places an image into the first
paragraph for each "record" but that's not what I want.
Dim str, i, spacepos, word
for wank = 1 to 7
if rsForums.EOF then exit for
if wank = 1 then
response.write "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'>"
End if
if wank = 2 then
response.write "<img id='picFloat' src='me.jpg'
class='picBorderThin'>"
End if
Response.Write "<p><span id='firstWords'>"
storyFix = replace(rsForums("T_MESSAGE"),vbcrlf & vbcrlf, "<p>")
story = replace(storyFix,"<p>", "</p>" & vbcrlf & "<p>")
for i = 1 to 4
spacepos = instr(story," " )
word = left(story,spacepos)
story = right(story,len(story)-spacepos)
response.write word
next
Response.Write "</span>"
Response.Write story
Response.Write "</p>" & vbcrlf & vbcrlf & "<hr>"
rsForums.MoveNext
next
rsForums.Close
Set rsForums = nothing
>
I wouldn't do this like this...
>
At some stage, each story/article is entered into a database. It's at
that point that I would manipulate it in the way you want. That way,
the operation is only ever performed once for each story, rather than
every time a page is requested.
>
Anyhoo, you need to break the problem down in the opposite order in
which you have. The first thing you need to do is to break the story
into paragraphs. Whether on input or output, this can be done using
split(). You also need to put you images into an array, so you can get
them by index.
>
Now that you have an array of paragraphs, and an array of images, it's
easy to loop through from 0 to 6, prepending each paragraph with its
associated image html. Within that loop, you can conduct the operation
to style the first few words. You would create a string containing the
first 7 paragraphs (adding <ptags as needed). Then, if there are any
paragraphs left, you would need to loop through those to style the
first few words, and append them to your string. Then its ready for
input/output.
>
--
Mike Brind
>
I'm still getting this error. I'm running the script exactly as you
wrote it. What am I missing?
Microsoft VBScript runtime error '800a0005'
Invalid procedure call or argument: 'right'
/paraTest.asp, line 40
Mike Brind wrote:
It's not going to work because you are not changing the paragraph on
each loop. You change the variable from storyArray to story, but on
the next iteration, it goes back to storyArray again. At that point,
story is storyArray minus the first word, but when you enter the loop
again, storyArray(0) is still the same value as when you started (ie,
the whole paragraph with all words intact). Try replacing the example
you posted earlier with the bit I just posted, See if that works.
--
Mike Brind
the other john wrote:
for some reason now I'm getting this...odd...don't know why..
Microsoft VBScript runtime error '800a0005'
Invalid procedure call or argument: 'right'
/paraTest.asp, line 36
"right" didn't cause a problem before. To be clear about what I was
trying to do I should have include the entire script. I'm trying to
tweek array items after getting the first 4 words formatted.
Thanks for your help Mike, I'm so close now, this is awesome!!!
myStory = rsForums("T_MESSAGE")
para = vbcrlf & vbcrlf
storyArray = Split(myStory, para)
for i = 1 to 4
spacepos = instr(storyArray(0)," " )
word = left(storyArray(0),spacepos)
story = right(storyArray(0),len(storyArray(0))-spacepos)
next
storyArray(0) = "<span id='firstWords'>" & word & "</span>" & story
storyArray(0) = "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'><p>" & storyArray(0) & "</p><blockquote>An
importand quote from the story here<blockquote>"
storyArray(1) = storyArray(1) & "<img id='picFloat' src='me.jpg'
class='picBorderThin'>"
for each item in storyArray
Response.write "<p>" & item & "</p>" & vbcrlf
Next
Mike Brind wrote:
myStory = rsForums("T_MESSAGE")
>
paras = Split(myStory, vbcrlf & vbcrlf)
para = paras(0)
Response.Write "<span id='firstWords'>"
for i = 1 to 4
spacepos = instr(para," " )
word = left(para,spacepos)
Response.Write word
para= right(para,len(story)-spacepos)
next
>
Response.Write "</span>" & para
>
Each time the loop executes, it strips the first word from the
paragraph after writing it to the browser within the <spantags. The
closing </span tag is written after the loop finishes, with the
remainder of the paragraph after it.
>
--
Mike Brind
>
>
the other john wrote:
Tried this and it only delivers one word and appears to exit the loop.
In other words it appears to stylize the first word rather than the
desired first 4. Any ideas?
myStory = rsForums("T_MESSAGE")
para = vbcrlf & vbcrlf
storyArray = Split(myStory, para)
for i = 1 to 4
spacepos = instr(storyArray(0)," " )
word = left(storyArray(0),spacepos)
story = right(storyArray(0),len(storyArray(0))-spacepos)
next
storyArray(0) = "<span id='firstWords'>" & word & "</span>" & story
Thanks again!!!
the other john wrote:
Cool, this almost has it. But to make it even better is there a way
other than the For Each loop that I can use to access "part" of the
array? If I could just stylize specific parts of the array one way and
the rest just be other, like an if else sort of thing that would put
this thing to bed. The array works "great"....not I just need to
figure out how to work with just "parts" of it. I'm thinking the For
Each loop isn't going to work in this case since it's an all or nothing
sort of thing. I haven't worked with arrays that much and don't know
the possibilities.
>
Thanks Mike! Learning a lot here!!
>
>
Mike Brind wrote:
I'm no CSS expert, so you might be better off asking this in a style
sheet group. However, try putting the text in a <ptag
storyArray(0) = "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'><p>" & storyArray(0) & "</p>"
--
Mike Brind
the other john wrote:
I tried this and it seemed to work except now I have a style issue. The
problem is if the letter I want to be affected by p:first-letter isn't
actually at the beginning of the item it won't work and if I want the
first pic to appear at the top it has to be at the beginning of the
item. Ideas?
>
Thanks!!!
>
<style>
#picFloat {float:left;}
p:first-letter {color: #8B0000; font-size:
40px;font-family:times;float:left;}
#firstWords
{text-transform:uppercase;font-family:times;font-size:120%;}
</style>
'
'
myStory = rsForums("T_MESSAGE")
>
para = vbcrlf & vbcrlf
>
storyArray = Split(myStory, para)
storyArray(0) = "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'>" & storyArray(0)
storyArray(1) = storyArray(1) & "<img id='picFloat' src='me.jpg'
class='picBorderThin'>"
>
for each item in storyArray
Response.write "<p>" & item & "</p>"
Next
>
>
Mike Brind wrote:
Nope.
paras = split(mystring,vbcrlf & vbcrlf)
This returns a one-dimensional zero-based array of paragraphs, so the
first paragraph will be held in the element referenced as paras(0), the
second in paras(1) etc.
Response.Write Ubound(paras) + 1 will give you the total number of
paragraphs.
--
Mike Brind
the other john wrote:
will split() take this?
>
para = vbcrlf & vbcrlf
Split(mystring, para)
>
>
Mike Brind wrote:
Even more reason to perform the operation on input. When the customer
changes the brief to have more or less words stylized, I'll look
forward to presenting the budget cost of doing so on existing data :-)
--
Mike Brind
Bob Lehmann wrote:
At some stage, each story/article is entered into a database. It's at
that point that I would manipulate it in the way you want. That way,
the operation is only ever performed once for each story,
>
Good idea.....
>
Until the customer decides that they want the first 5 words stylized.
>
Bob Lehmann
>
>
"Mike Brind" <pa*******@hotmail.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
the other john wrote:
I'm trying to enhance a script to do the following things.
>
1). detect the first four words of a paragraph and stylize them
(already does that)
2). Capitalize and stylize the first letter of each paragraph (already
does that via style sheet)
3). Count the number of paragraphs (or number of "vbcrlf & vbcrfl") so
I can insert a images in specific places (i.e. I want to dynamically
insert image 1 in paragraph 1, image 2 into para 2, etc.)
>
This third item I can't figure out. I've tried it a few ways but keep
running to problems.
>
Thanks!!!
>
The following script was provided by Mike Brind, thanks Mike. It
currently can produce results for the first 2 items I listed above but
not exactly the way I want it to. It places an image into the first
paragraph for each "record" but that's not what I want.
>
Dim str, i, spacepos, word
for wank = 1 to 7
if rsForums.EOF then exit for
if wank = 1 then
response.write "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'>"
End if
if wank = 2 then
response.write "<img id='picFloat' src='me.jpg'
class='picBorderThin'>"
End if
Response.Write "<p><span id='firstWords'>"
storyFix = replace(rsForums("T_MESSAGE"),vbcrlf & vbcrlf, "<p>")
story = replace(storyFix,"<p>", "</p>" & vbcrlf & "<p>")
for i = 1 to 4
spacepos = instr(story," " )
word = left(story,spacepos)
story = right(story,len(story)-spacepos)
response.write word
next
>
Response.Write "</span>"
Response.Write story
Response.Write "</p>" & vbcrlf & vbcrlf & "<hr>"
rsForums.MoveNext
next
rsForums.Close
Set rsForums = nothing
I wouldn't do this like this...
At some stage, each story/article is entered into a database. It's at
that point that I would manipulate it in the way you want. That way,
the operation is only ever performed once for each story, rather than
every time a page is requested.
Anyhoo, you need to break the problem down in the opposite order in
which you have. The first thing you need to do is to break the story
into paragraphs. Whether on input or output, this can be done using
split(). You also need to put you images into an array, so you can get
them by index.
Now that you have an array of paragraphs, and an array of images, it's
easy to loop through from 0 to 6, prepending each paragraph with its
associated image html. Within that loop, you can conduct the operation
to style the first few words. You would create a string containing the
first 7 paragraphs (adding <ptags as needed). Then, if there are any
paragraphs left, you would need to loop through those to style the
first few words, and append them to your string. Then its ready for
input/output.
--
Mike Brind
oh, I see the problem now. there was still a "story" in there that
needed to be changed to "para". Ok, this worked...but how to I print
the rest of the array? Is there a way to use a for each loop and
skipping the first array item?
the other john wrote:
I'm still getting this error. I'm running the script exactly as you
wrote it. What am I missing?
Microsoft VBScript runtime error '800a0005'
Invalid procedure call or argument: 'right'
/paraTest.asp, line 40
Mike Brind wrote:
It's not going to work because you are not changing the paragraph on
each loop. You change the variable from storyArray to story, but on
the next iteration, it goes back to storyArray again. At that point,
story is storyArray minus the first word, but when you enter the loop
again, storyArray(0) is still the same value as when you started (ie,
the whole paragraph with all words intact). Try replacing the example
you posted earlier with the bit I just posted, See if that works.
--
Mike Brind
the other john wrote:
for some reason now I'm getting this...odd...don't know why..
>
Microsoft VBScript runtime error '800a0005'
>
Invalid procedure call or argument: 'right'
>
/paraTest.asp, line 36
>
>
"right" didn't cause a problem before. To be clear about what I was
trying to do I should have include the entire script. I'm trying to
tweek array items after getting the first 4 words formatted.
>
Thanks for your help Mike, I'm so close now, this is awesome!!!
>
>
>
myStory = rsForums("T_MESSAGE")
>
para = vbcrlf & vbcrlf
>
storyArray = Split(myStory, para)
for i = 1 to 4
spacepos = instr(storyArray(0)," " )
word = left(storyArray(0),spacepos)
story = right(storyArray(0),len(storyArray(0))-spacepos)
next
>
storyArray(0) = "<span id='firstWords'>" & word & "</span>" & story
>
storyArray(0) = "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'><p>" & storyArray(0) & "</p><blockquote>An
importand quote from the story here<blockquote>"
>
storyArray(1) = storyArray(1) & "<img id='picFloat' src='me.jpg'
class='picBorderThin'>"
>
>
for each item in storyArray
Response.write "<p>" & item & "</p>" & vbcrlf
Next
>
>
Mike Brind wrote:
myStory = rsForums("T_MESSAGE")
paras = Split(myStory, vbcrlf & vbcrlf)
para = paras(0)
Response.Write "<span id='firstWords'>"
for i = 1 to 4
spacepos = instr(para," " )
word = left(para,spacepos)
Response.Write word
para= right(para,len(story)-spacepos)
next
Response.Write "</span>" & para
Each time the loop executes, it strips the first word from the
paragraph after writing it to the browser within the <spantags. The
closing </span tag is written after the loop finishes, with the
remainder of the paragraph after it.
--
Mike Brind
the other john wrote:
Tried this and it only delivers one word and appears to exit the loop.
In other words it appears to stylize the first word rather than the
desired first 4. Any ideas?
>
myStory = rsForums("T_MESSAGE")
>
para = vbcrlf & vbcrlf
>
storyArray = Split(myStory, para)
>
for i = 1 to 4
spacepos = instr(storyArray(0)," " )
word = left(storyArray(0),spacepos)
story = right(storyArray(0),len(storyArray(0))-spacepos)
next
>
storyArray(0) = "<span id='firstWords'>" & word & "</span>" & story
>
>
>
Thanks again!!!
>
>
the other john wrote:
Cool, this almost has it. But to make it even better is there a way
other than the For Each loop that I can use to access "part" of the
array? If I could just stylize specific parts of the array one way and
the rest just be other, like an if else sort of thing that would put
this thing to bed. The array works "great"....not I just need to
figure out how to work with just "parts" of it. I'm thinking the For
Each loop isn't going to work in this case since it's an all or nothing
sort of thing. I haven't worked with arrays that much and don't know
the possibilities.
Thanks Mike! Learning a lot here!!
Mike Brind wrote:
I'm no CSS expert, so you might be better off asking this in a style
sheet group. However, try putting the text in a <ptag
>
storyArray(0) = "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'><p>" & storyArray(0) & "</p>"
>
--
Mike Brind
>
the other john wrote:
I tried this and it seemed to work except now I have a style issue. The
problem is if the letter I want to be affected by p:first-letter isn't
actually at the beginning of the item it won't work and if I want the
first pic to appear at the top it has to be at the beginning of the
item. Ideas?
Thanks!!!
<style>
#picFloat {float:left;}
p:first-letter {color: #8B0000; font-size:
40px;font-family:times;float:left;}
#firstWords
{text-transform:uppercase;font-family:times;font-size:120%;}
</style>
'
'
myStory = rsForums("T_MESSAGE")
para = vbcrlf & vbcrlf
storyArray = Split(myStory, para)
storyArray(0) = "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'>" & storyArray(0)
storyArray(1) = storyArray(1) & "<img id='picFloat' src='me.jpg'
class='picBorderThin'>"
for each item in storyArray
Response.write "<p>" & item & "</p>"
Next
Mike Brind wrote:
Nope.
>
paras = split(mystring,vbcrlf & vbcrlf)
>
This returns a one-dimensional zero-based array of paragraphs, so the
first paragraph will be held in the element referenced as paras(0), the
second in paras(1) etc.
>
Response.Write Ubound(paras) + 1 will give you the total number of
paragraphs.
>
--
Mike Brind
>
the other john wrote:
will split() take this?
para = vbcrlf & vbcrlf
Split(mystring, para)
Mike Brind wrote:
Even more reason to perform the operation on input. When the customer
changes the brief to have more or less words stylized, I'll look
forward to presenting the budget cost of doing so on existing data :-)
>
--
Mike Brind
>
Bob Lehmann wrote:
At some stage, each story/article is entered into a database. It's at
that point that I would manipulate it in the way you want. That way,
the operation is only ever performed once for each story,
Good idea.....
Until the customer decides that they want the first 5 words stylized.
Bob Lehmann
"Mike Brind" <pa*******@hotmail.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
>
the other john wrote:
I'm trying to enhance a script to do the following things.
1). detect the first four words of a paragraph and stylize them
(already does that)
2). Capitalize and stylize the first letter of each paragraph (already
does that via style sheet)
3). Count the number of paragraphs (or number of "vbcrlf & vbcrfl") so
I can insert a images in specific places (i.e. I want to dynamically
insert image 1 in paragraph 1, image 2 into para 2, etc.)
This third item I can't figure out. I've tried it a few ways but keep
running to problems.
Thanks!!!
The following script was provided by Mike Brind, thanks Mike. It
currently can produce results for the first 2 items I listed above but
not exactly the way I want it to. It places an image into the first
paragraph for each "record" but that's not what I want.
Dim str, i, spacepos, word
for wank = 1 to 7
if rsForums.EOF then exit for
if wank = 1 then
response.write "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'>"
End if
if wank = 2 then
response.write "<img id='picFloat' src='me.jpg'
class='picBorderThin'>"
End if
Response.Write "<p><span id='firstWords'>"
storyFix = replace(rsForums("T_MESSAGE"),vbcrlf & vbcrlf, "<p>")
story = replace(storyFix,"<p>", "</p>" & vbcrlf & "<p>")
for i = 1 to 4
spacepos = instr(story," " )
word = left(story,spacepos)
story = right(story,len(story)-spacepos)
response.write word
next
Response.Write "</span>"
Response.Write story
Response.Write "</p>" & vbcrlf & vbcrlf & "<hr>"
rsForums.MoveNext
next
rsForums.Close
Set rsForums = nothing
>
I wouldn't do this like this...
>
At some stage, each story/article is entered into a database. It's at
that point that I would manipulate it in the way you want. That way,
the operation is only ever performed once for each story, rather than
every time a page is requested.
>
Anyhoo, you need to break the problem down in the opposite order in
which you have. The first thing you need to do is to break the story
into paragraphs. Whether on input or output, this can be done using
split(). You also need to put you images into an array, so you can get
them by index.
>
Now that you have an array of paragraphs, and an array of images, it's
easy to loop through from 0 to 6, prepending each paragraph with its
associated image html. Within that loop, you can conduct the operation
to style the first few words. You would create a string containing the
first 7 paragraphs (adding <ptags as needed). Then, if there are any
paragraphs left, you would need to loop through those to style the
first few words, and append them to your string. Then its ready for
input/output.
>
--
Mike Brind
>
I answered that in my first reply.
--
Mike Brind
the other john wrote:
oh, I see the problem now. there was still a "story" in there that
needed to be changed to "para". Ok, this worked...but how to I print
the rest of the array? Is there a way to use a for each loop and
skipping the first array item?
<snip>
I wouldn't do this like this...
At some stage, each story/article is entered into a database. It's at
that point that I would manipulate it in the way you want. That way,
the operation is only ever performed once for each story, rather than
every time a page is requested.
Anyhoo, you need to break the problem down in the opposite order in
which you have. The first thing you need to do is to break the story
into paragraphs. Whether on input or output, this can be done using
split(). You also need to put you images into an array, so you can get
them by index.
Now that you have an array of paragraphs, and an array of images, it's
easy to loop through from 0 to 6, prepending each paragraph with its
associated image html. Within that loop, you can conduct the operation
to style the first few words. You would create a string containing the
first 7 paragraphs (adding <ptags as needed). Then, if there are any
paragraphs left, you would need to loop through those to style the
first few words, and append them to your string. Then its ready for
input/output.
--
Mike Brind
what's confusing me is how get the paragraph that's stylizing the first
4 words into a variable instead of writing it to the page.
Response.write appears to be whats allowing the loop to go on to the
next word. How do I "not" write to the page and put into a variable
instead so I can prepend it further?
I don't know how I got this far without having a better handle on
control structures, yikes. For example, is it possible to use
conditionals inside of a For Each loop?
For each item in thisArray
If item = whatever then
do this
Else
do somethinge else
End if
Next
I tried this and it didn't work so I assume answer is no but thought
I'd ask just the same.
Thanks!!!!
the other john wrote:
oh, I see the problem now. there was still a "story" in there that
needed to be changed to "para". Ok, this worked...but how to I print
the rest of the array? Is there a way to use a for each loop and
skipping the first array item?
the other john wrote:
I'm still getting this error. I'm running the script exactly as you
wrote it. What am I missing?
Microsoft VBScript runtime error '800a0005'
Invalid procedure call or argument: 'right'
/paraTest.asp, line 40
Mike Brind wrote:
It's not going to work because you are not changing the paragraph on
each loop. You change the variable from storyArray to story, but on
the next iteration, it goes back to storyArray again. At that point,
story is storyArray minus the first word, but when you enter the loop
again, storyArray(0) is still the same value as when you started (ie,
the whole paragraph with all words intact). Try replacing the example
you posted earlier with the bit I just posted, See if that works.
>
--
Mike Brind
>
>
>
the other john wrote:
for some reason now I'm getting this...odd...don't know why..
Microsoft VBScript runtime error '800a0005'
Invalid procedure call or argument: 'right'
/paraTest.asp, line 36
"right" didn't cause a problem before. To be clear about what I was
trying to do I should have include the entire script. I'm trying to
tweek array items after getting the first 4 words formatted.
Thanks for your help Mike, I'm so close now, this is awesome!!!
myStory = rsForums("T_MESSAGE")
para = vbcrlf & vbcrlf
storyArray = Split(myStory, para)
for i = 1 to 4
spacepos = instr(storyArray(0)," " )
word = left(storyArray(0),spacepos)
story = right(storyArray(0),len(storyArray(0))-spacepos)
next
storyArray(0) = "<span id='firstWords'>" & word & "</span>" & story
storyArray(0) = "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'><p>" & storyArray(0) & "</p><blockquote>An
importand quote from the story here<blockquote>"
storyArray(1) = storyArray(1) & "<img id='picFloat' src='me.jpg'
class='picBorderThin'>"
for each item in storyArray
Response.write "<p>" & item & "</p>" & vbcrlf
Next
Mike Brind wrote:
myStory = rsForums("T_MESSAGE")
>
paras = Split(myStory, vbcrlf & vbcrlf)
para = paras(0)
Response.Write "<span id='firstWords'>"
for i = 1 to 4
spacepos = instr(para," " )
word = left(para,spacepos)
Response.Write word
para= right(para,len(story)-spacepos)
next
>
Response.Write "</span>" & para
>
Each time the loop executes, it strips the first word from the
paragraph after writing it to the browser within the <spantags. The
closing </span tag is written after the loop finishes, with the
remainder of the paragraph after it.
>
--
Mike Brind
>
>
the other john wrote:
Tried this and it only delivers one word and appears to exit the loop.
In other words it appears to stylize the first word rather than the
desired first 4. Any ideas?
myStory = rsForums("T_MESSAGE")
para = vbcrlf & vbcrlf
storyArray = Split(myStory, para)
for i = 1 to 4
spacepos = instr(storyArray(0)," " )
word = left(storyArray(0),spacepos)
story = right(storyArray(0),len(storyArray(0))-spacepos)
next
storyArray(0) = "<span id='firstWords'>" & word & "</span>" & story
Thanks again!!!
the other john wrote:
Cool, this almost has it. But to make it even better is there a way
other than the For Each loop that I can use to access "part" of the
array? If I could just stylize specific parts of the array one way and
the rest just be other, like an if else sort of thing that would put
this thing to bed. The array works "great"....not I just need to
figure out how to work with just "parts" of it. I'm thinking the For
Each loop isn't going to work in this case since it's an all or nothing
sort of thing. I haven't worked with arrays that much and don't know
the possibilities.
>
Thanks Mike! Learning a lot here!!
>
>
Mike Brind wrote:
I'm no CSS expert, so you might be better off asking this in a style
sheet group. However, try putting the text in a <ptag
storyArray(0) = "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'><p>" & storyArray(0) & "</p>"
--
Mike Brind
the other john wrote:
I tried this and it seemed to work except now I have a style issue. The
problem is if the letter I want to be affected by p:first-letter isn't
actually at the beginning of the item it won't work and if I want the
first pic to appear at the top it has to be at the beginning of the
item. Ideas?
>
Thanks!!!
>
<style>
#picFloat {float:left;}
p:first-letter {color: #8B0000; font-size:
40px;font-family:times;float:left;}
#firstWords
{text-transform:uppercase;font-family:times;font-size:120%;}
</style>
'
'
myStory = rsForums("T_MESSAGE")
>
para = vbcrlf & vbcrlf
>
storyArray = Split(myStory, para)
storyArray(0) = "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'>" & storyArray(0)
storyArray(1) = storyArray(1) & "<img id='picFloat' src='me.jpg'
class='picBorderThin'>"
>
for each item in storyArray
Response.write "<p>" & item & "</p>"
Next
>
>
Mike Brind wrote:
Nope.
paras = split(mystring,vbcrlf & vbcrlf)
This returns a one-dimensional zero-based array of paragraphs, so the
first paragraph will be held in the element referenced as paras(0), the
second in paras(1) etc.
Response.Write Ubound(paras) + 1 will give you the total number of
paragraphs.
--
Mike Brind
the other john wrote:
will split() take this?
>
para = vbcrlf & vbcrlf
Split(mystring, para)
>
>
Mike Brind wrote:
Even more reason to perform the operation on input. When the customer
changes the brief to have more or less words stylized, I'll look
forward to presenting the budget cost of doing so on existing data :-)
--
Mike Brind
Bob Lehmann wrote:
At some stage, each story/article is entered into a database. It's at
that point that I would manipulate it in the way you want. That way,
the operation is only ever performed once for each story,
>
Good idea.....
>
Until the customer decides that they want the first 5 words stylized.
>
Bob Lehmann
>
>
"Mike Brind" <pa*******@hotmail.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
the other john wrote:
I'm trying to enhance a script to do the following things.
>
1). detect the first four words of a paragraph and stylize them
(already does that)
2). Capitalize and stylize the first letter of each paragraph (already
does that via style sheet)
3). Count the number of paragraphs (or number of "vbcrlf & vbcrfl") so
I can insert a images in specific places (i.e. I want to dynamically
insert image 1 in paragraph 1, image 2 into para 2, etc.)
>
This third item I can't figure out. I've tried it a few ways but keep
running to problems.
>
Thanks!!!
>
The following script was provided by Mike Brind, thanks Mike. It
currently can produce results for the first 2 items I listed above but
not exactly the way I want it to. It places an image into the first
paragraph for each "record" but that's not what I want.
>
Dim str, i, spacepos, word
for wank = 1 to 7
if rsForums.EOF then exit for
if wank = 1 then
response.write "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'>"
End if
if wank = 2 then
response.write "<img id='picFloat' src='me.jpg'
class='picBorderThin'>"
End if
Response.Write "<p><span id='firstWords'>"
storyFix = replace(rsForums("T_MESSAGE"),vbcrlf & vbcrlf, "<p>")
story = replace(storyFix,"<p>", "</p>" & vbcrlf & "<p>")
for i = 1 to 4
spacepos = instr(story," " )
word = left(story,spacepos)
story = right(story,len(story)-spacepos)
response.write word
next
>
Response.Write "</span>"
Response.Write story
Response.Write "</p>" & vbcrlf & vbcrlf & "<hr>"
rsForums.MoveNext
next
rsForums.Close
Set rsForums = nothing
I wouldn't do this like this...
At some stage, each story/article is entered into a database. It's at
that point that I would manipulate it in the way you want. That way,
the operation is only ever performed once for each story, rather than
every time a page is requested.
Anyhoo, you need to break the problem down in the opposite order in
which you have. The first thing you need to do is to break the story
into paragraphs. Whether on input or output, this can be done using
split(). You also need to put you images into an array, so you can get
them by index.
Now that you have an array of paragraphs, and an array of images, it's
easy to loop through from 0 to 6, prepending each paragraph with its
associated image html. Within that loop, you can conduct the operation
to style the first few words. You would create a string containing the
first 7 paragraphs (adding <ptags as needed). Then, if there are any
paragraphs left, you would need to loop through those to style the
first few words, and append them to your string. Then its ready for
input/output.
--
Mike Brind
LOL, ok, I found a solution albeit a less than elegant one....
myStory = rsForums("T_MESSAGE")
storyArray = Split(myStory, vbcrlf & vbcrlf)
para = storyArray(0)
Response.Write "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'><p><span id='firstWords'>"
for i = 1 to 4
spacepos = instr(para," " )
word = left(para,spacepos)
Response.Write word
para= right(para,len(para)-spacepos)
next
Response.Write "</span>" & para & "</p><blockquote>A quote on the side
somewhere</blockquote>" & vbcrlf
storyArray(1) = storyArray(1) & "<img id='picFloat' src='me.jpg'
class='picBorderThin'>"
for paraLoop = LBound(storyArray)+1 to UBound(storyArray)
Response.write "<p>" & storyArray(paraLoop) & "</p>" & vbcrlf
next
Thanks Mike for everything! Any other ideas I appreciate it!
the other john wrote:
what's confusing me is how get the paragraph that's stylizing the first
4 words into a variable instead of writing it to the page.
Response.write appears to be whats allowing the loop to go on to the
next word. How do I "not" write to the page and put into a variable
instead so I can prepend it further?
I don't know how I got this far without having a better handle on
control structures, yikes. For example, is it possible to use
conditionals inside of a For Each loop?
For each item in thisArray
If item = whatever then
do this
Else
do somethinge else
End if
Next
I tried this and it didn't work so I assume answer is no but thought
I'd ask just the same.
Thanks!!!!
the other john wrote:
oh, I see the problem now. there was still a "story" in there that
needed to be changed to "para". Ok, this worked...but how to I print
the rest of the array? Is there a way to use a for each loop and
skipping the first array item?
the other john wrote:
I'm still getting this error. I'm running the script exactly as you
wrote it. What am I missing?
>
>
Microsoft VBScript runtime error '800a0005'
>
Invalid procedure call or argument: 'right'
>
/paraTest.asp, line 40
>
Mike Brind wrote:
It's not going to work because you are not changing the paragraph on
each loop. You change the variable from storyArray to story, but on
the next iteration, it goes back to storyArray again. At that point,
story is storyArray minus the first word, but when you enter the loop
again, storyArray(0) is still the same value as when you started (ie,
the whole paragraph with all words intact). Try replacing the example
you posted earlier with the bit I just posted, See if that works.
--
Mike Brind
the other john wrote:
for some reason now I'm getting this...odd...don't know why..
>
Microsoft VBScript runtime error '800a0005'
>
Invalid procedure call or argument: 'right'
>
/paraTest.asp, line 36
>
>
"right" didn't cause a problem before. To be clear about what I was
trying to do I should have include the entire script. I'm trying to
tweek array items after getting the first 4 words formatted.
>
Thanks for your help Mike, I'm so close now, this is awesome!!!
>
>
>
myStory = rsForums("T_MESSAGE")
>
para = vbcrlf & vbcrlf
>
storyArray = Split(myStory, para)
for i = 1 to 4
spacepos = instr(storyArray(0)," " )
word = left(storyArray(0),spacepos)
story = right(storyArray(0),len(storyArray(0))-spacepos)
next
>
storyArray(0) = "<span id='firstWords'>" & word & "</span>" & story
>
storyArray(0) = "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'><p>" & storyArray(0) & "</p><blockquote>An
importand quote from the story here<blockquote>"
>
storyArray(1) = storyArray(1) & "<img id='picFloat' src='me.jpg'
class='picBorderThin'>"
>
>
for each item in storyArray
Response.write "<p>" & item & "</p>" & vbcrlf
Next
>
>
Mike Brind wrote:
myStory = rsForums("T_MESSAGE")
paras = Split(myStory, vbcrlf & vbcrlf)
para = paras(0)
Response.Write "<span id='firstWords'>"
for i = 1 to 4
spacepos = instr(para," " )
word = left(para,spacepos)
Response.Write word
para= right(para,len(story)-spacepos)
next
Response.Write "</span>" & para
Each time the loop executes, it strips the first word from the
paragraph after writing it to the browser within the <spantags. The
closing </span tag is written after the loop finishes, with the
remainder of the paragraph after it.
--
Mike Brind
the other john wrote:
Tried this and it only delivers one word and appears to exit the loop.
In other words it appears to stylize the first word rather than the
desired first 4. Any ideas?
>
myStory = rsForums("T_MESSAGE")
>
para = vbcrlf & vbcrlf
>
storyArray = Split(myStory, para)
>
for i = 1 to 4
spacepos = instr(storyArray(0)," " )
word = left(storyArray(0),spacepos)
story = right(storyArray(0),len(storyArray(0))-spacepos)
next
>
storyArray(0) = "<span id='firstWords'>" & word & "</span>" & story
>
>
>
Thanks again!!!
>
>
the other john wrote:
Cool, this almost has it. But to make it even better is there a way
other than the For Each loop that I can use to access "part" of the
array? If I could just stylize specific parts of the array one way and
the rest just be other, like an if else sort of thing that would put
this thing to bed. The array works "great"....not I just need to
figure out how to work with just "parts" of it. I'm thinking the For
Each loop isn't going to work in this case since it's an all or nothing
sort of thing. I haven't worked with arrays that much and don't know
the possibilities.
Thanks Mike! Learning a lot here!!
Mike Brind wrote:
I'm no CSS expert, so you might be better off asking this in a style
sheet group. However, try putting the text in a <ptag
>
storyArray(0) = "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'><p>" & storyArray(0) & "</p>"
>
--
Mike Brind
>
the other john wrote:
I tried this and it seemed to work except now I have a style issue. The
problem is if the letter I want to be affected by p:first-letter isn't
actually at the beginning of the item it won't work and if I want the
first pic to appear at the top it has to be at the beginning of the
item. Ideas?
Thanks!!!
<style>
#picFloat {float:left;}
p:first-letter {color: #8B0000; font-size:
40px;font-family:times;float:left;}
#firstWords
{text-transform:uppercase;font-family:times;font-size:120%;}
</style>
'
'
myStory = rsForums("T_MESSAGE")
para = vbcrlf & vbcrlf
storyArray = Split(myStory, para)
storyArray(0) = "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'>" & storyArray(0)
storyArray(1) = storyArray(1) & "<img id='picFloat' src='me.jpg'
class='picBorderThin'>"
for each item in storyArray
Response.write "<p>" & item & "</p>"
Next
Mike Brind wrote:
Nope.
>
paras = split(mystring,vbcrlf & vbcrlf)
>
This returns a one-dimensional zero-based array of paragraphs, so the
first paragraph will be held in the element referenced as paras(0), the
second in paras(1) etc.
>
Response.Write Ubound(paras) + 1 will give you the total number of
paragraphs.
>
--
Mike Brind
>
the other john wrote:
will split() take this?
para = vbcrlf & vbcrlf
Split(mystring, para)
Mike Brind wrote:
Even more reason to perform the operation on input. When the customer
changes the brief to have more or less words stylized, I'll look
forward to presenting the budget cost of doing so on existing data :-)
>
--
Mike Brind
>
Bob Lehmann wrote:
At some stage, each story/article is entered into a database. It's at
that point that I would manipulate it in the way you want. That way,
the operation is only ever performed once for each story,
Good idea.....
Until the customer decides that they want the first 5 words stylized.
Bob Lehmann
"Mike Brind" <pa*******@hotmail.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
>
the other john wrote:
I'm trying to enhance a script to do the following things.
1). detect the first four words of a paragraph and stylize them
(already does that)
2). Capitalize and stylize the first letter of each paragraph (already
does that via style sheet)
3). Count the number of paragraphs (or number of "vbcrlf & vbcrfl") so
I can insert a images in specific places (i.e. I want to dynamically
insert image 1 in paragraph 1, image 2 into para 2, etc.)
This third item I can't figure out. I've tried it a few ways but keep
running to problems.
Thanks!!!
The following script was provided by Mike Brind, thanks Mike. It
currently can produce results for the first 2 items I listed above but
not exactly the way I want it to. It places an image into the first
paragraph for each "record" but that's not what I want.
Dim str, i, spacepos, word
for wank = 1 to 7
if rsForums.EOF then exit for
if wank = 1 then
response.write "<img id='picFloat' src='testoboy.jpg'
class='picBorderThin'>"
End if
if wank = 2 then
response.write "<img id='picFloat' src='me.jpg'
class='picBorderThin'>"
End if
Response.Write "<p><span id='firstWords'>"
storyFix = replace(rsForums("T_MESSAGE"),vbcrlf & vbcrlf, "<p>")
story = replace(storyFix,"<p>", "</p>" & vbcrlf & "<p>")
for i = 1 to 4
spacepos = instr(story," " )
word = left(story,spacepos)
story = right(story,len(story)-spacepos)
response.write word
next
Response.Write "</span>"
Response.Write story
Response.Write "</p>" & vbcrlf & vbcrlf & "<hr>"
rsForums.MoveNext
next
rsForums.Close
Set rsForums = nothing
>
I wouldn't do this like this...
>
At some stage, each story/article is entered into a database. It's at
that point that I would manipulate it in the way you want. That way,
the operation is only ever performed once for each story, rather than
every time a page is requested.
>
Anyhoo, you need to break the problem down in the opposite order in
which you have. The first thing you need to do is to break the story
into paragraphs. Whether on input or output, this can be done using
split(). You also need to put you images into an array, so you can get
them by index.
>
Now that you have an array of paragraphs, and an array of images, it's
easy to loop through from 0 to 6, prepending each paragraph with its
associated image html. Within that loop, you can conduct the operation
to style the first few words. You would create a string containing the
first 7 paragraphs (adding <ptags as needed). Then, if there are any
paragraphs left, you would need to loop through those to style the
first few words, and append them to your string. Then its ready for
input/output.
>
--
Mike Brind
>
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: fig000 |
last post by:
Hi,
I'm relatively new to Javascript so please bear with me on what
might sound like silly questions.
This is what I want to do:
I'm working in classic asp (I have to for this project). I...
|
by: anon |
last post by:
Post Forwarding question......
For this control below,
<asp:Button runat="server" PostTargetUrl="page2.aspx" />
The Attribute: PostTargetUrl="page2.aspx"
Is this PostTargetUrl Attribute...
|
by: terence.parker |
last post by:
I am often faced with the dilemma of whether to use a JOIN query across
three tables in order to grab a bunch of results - or whether to create
another table to represent what I want. The latter is...
|
by: Sebastian Hiller |
last post by:
Hello,
i'm new to .Net (i'm using VB as language and i'm working in the
code-behind mode) and i can't solve the following problem:
I have a WebForm and want to Add a UserControl...
|
by: Brad |
last post by:
I have another hopefully simple question. I am so used to writing VB .Net
windows apps that there are some things in ASP .Net that just does not easily
cross over. I know how to pass variables to...
|
by: Javier Martinez |
last post by:
Hi
I have asp application in a machine with a virtual directory referring a
shared directory in another machine
When I try to load any aspx page of my portal I get the following error:
...
|
by: Eric_Dexter |
last post by:
def simplecsdtoorc(filename):
file = open(filename,"r")
alllines = file.read_until("</CsInstruments>")
pattern1 = re.compile("</")
orcfilename = filename + "orc"
for line in alllines:
if not...
|
by: David Mathog |
last post by:
On a Solaris 8 system if a user "joe" logs in, for instance via ssh,
cuserid() returns "joe". That's the expected behavior and so far so
good. However if that user then does:
% su - sally
...
|
by: shookim |
last post by:
I don't care how one suggests I do it, but I've been searching for days
on how to implement this concept. I'm trying to use some kind of grid
control (doesn't have to be a grid control, whatever...
|
by: MichaelK |
last post by:
Hello.
I have all data already collected on the current page?
I want to open another window with the form, fill the fields and submit that
form.
So basically the question is how can I fill all...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
|
by: WisdomUfot |
last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
|
by: Carina712 |
last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
|
by: Rahul1995seven |
last post by:
Introduction:
In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
|
by: Ricardo de Mila |
last post by:
Dear people, good afternoon...
I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control.
Than I need to discover what...
|
by: Johno34 |
last post by:
I have this click event on my form. It speaks to a Datasheet Subform
Private Sub Command260_Click()
Dim r As DAO.Recordset
Set r = Form_frmABCD.Form.RecordsetClone
r.MoveFirst
Do
If...
|
by: jack2019x |
last post by:
hello, Is there code or static lib for hook swapchain present?
I wanna hook dxgi swapchain present for dx11 and dx9.
| |