Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP General (http://www.velocityreviews.com/forums/f65-asp-general.html)
-   -   Another VB question (http://www.velocityreviews.com/forums/t801675-another-vb-question.html)

the other john 07-20-2006 02:17 PM

Another VB question
 
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


Rob Meade 07-20-2006 02:48 PM

Re: Another VB question
 
"the other john" wrote...

> for wank = 1 to 7
> next


Talk about stamina!!!

:oD

Rob



the other john 07-20-2006 03:09 PM

Re: Another VB question
 
;-)


Rob Meade wrote:
> "the other john" wrote...
>
> > for wank = 1 to 7
> > next

>
> Talk about stamina!!!
>
> :oD
>
> Rob



Mike Brind 07-20-2006 07:36 PM

Re: Another VB question
 

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 <p> tags 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


Bob Lehmann 07-20-2006 11:31 PM

Re: Another VB question
 
> 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" <paxtonend@hotmail.com> wrote in message
news:1153424196.458612.25370@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 <p> tags 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
>




Mike Brind 07-21-2006 07:01 AM

Re: Another VB question
 
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" <paxtonend@hotmail.com> wrote in message
> news:1153424196.458612.25370@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 <p> tags 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
> >



the other john 07-21-2006 03:43 PM

Re: Another VB question
 
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" <paxtonend@hotmail.com> wrote in message
> > news:1153424196.458612.25370@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 <p> tags 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
> > >



Mike Brind 07-21-2006 08:07 PM

Re: Another VB question
 
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" <paxtonend@hotmail.com> wrote in message
> > > news:1153424196.458612.25370@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 <p> tags 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
> > > >



the other john 07-21-2006 08:36 PM

Re: Another VB question
 
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" <paxtonend@hotmail.com> wrote in message
> > > > news:1153424196.458612.25370@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 <p> tags 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
> > > > >



Mike Brind 07-21-2006 09:54 PM

Re: Another VB question
 
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 <p> tag

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" <paxtonend@hotmail.com> wrote in message
> > > > > news:1153424196.458612.25370@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 <p> tags 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
> > > > > >




All times are GMT. The time now is 08:33 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.