Another solution for this??

Discussion in 'ASP General' started by the other john, Apr 11, 2007.

  1. This is a script someone here helped me with a while back and I am
    very grateful for the help. I am stumped however as to how to change
    it slightly.

    This is the script...

    storyArray = Split(myStory, vbcrlf & vbcrlf)
    para = storyArray(0)

    'setup the loop for the first words here
    Response.write "<p><span id='firstWords'>"

    for i = 1 to 4
    spacepos = instr(para," " )
    word = left(para,spacepos)
    Response.Write word 'this is the line I need to create a variable
    instead
    para = right(para,len(para)-spacepos)
    next

    'close the first words loop and print the remaining words in the first
    paragraph
    Response.Write "</span>" & para & "</p>" & vbcrlf

    All this was designed to do it to is to take to take the first array
    item (a paragraph) and enclose the first words (in this case the first
    4) in style tags. It works perfectly however, instead of "printing"
    the words with this line "Response.Write word", I need to instead
    place the words into a variable instead of just printing them, in
    other words, create a string of the first 4 words and place them into
    a variable like "firstWords" or whatever so I can call on it at a
    later time in the script. It should just be a simple thing but it's
    not turning out this way. I'd "really" appreciate ideas.

    Thanks!!

    John
     
    the other john, Apr 11, 2007
    #1
    1. Advertising

  2. "the other john" <> wrote in message
    news:...
    > This is a script someone here helped me with a while back and I am
    > very grateful for the help. I am stumped however as to how to change
    > it slightly.
    >
    > This is the script...
    >
    > storyArray = Split(myStory, vbcrlf & vbcrlf)
    > para = storyArray(0)
    >
    > 'setup the loop for the first words here
    > Response.write "<p><span id='firstWords'>"
    >


    dim aVariable
    aVariable = ""

    > for i = 1 to 4
    > spacepos = instr(para," " )
    > word = left(para,spacepos)
    > Response.Write word 'this is the line I need to create a variable
    > instead


    aVariable = aVariable & word


    > para = right(para,len(para)-spacepos)
    > next
    >
    > 'close the first words loop and print the remaining words in the first
    > paragraph
    > Response.Write "</span>" & para & "</p>" & vbcrlf
    >
    > All this was designed to do it to is to take to take the first array
    > item (a paragraph) and enclose the first words (in this case the first
    > 4) in style tags. It works perfectly however, instead of "printing"
    > the words with this line "Response.Write word", I need to instead
    > place the words into a variable instead of just printing them, in
    > other words, create a string of the first 4 words and place them into
    > a variable like "firstWords" or whatever so I can call on it at a
    > later time in the script. It should just be a simple thing but it's
    > not turning out this way. I'd "really" appreciate ideas.
    >
    > Thanks!!
    >
    > John
    >
     
    ThatsIT.net.au, Apr 11, 2007
    #2
    1. Advertising

  3. On Apr 11, 10:55 am, "ThatsIT.net.au" <me@thatsit> wrote:
    > "the other john" <> wrote in messagenews:...
    >
    > > This is a script someone here helped me with a while back and I am
    > > very grateful for the help. I am stumped however as to how to change
    > > it slightly.

    >
    > > This is the script...

    >
    > > storyArray = Split(myStory, vbcrlf & vbcrlf)
    > > para = storyArray(0)

    >
    > > 'setup the loop for the first words here
    > > Response.write "<p><span id='firstWords'>"

    >
    > dim aVariable
    > aVariable = ""
    >
    > > for i = 1 to 4
    > > spacepos = instr(para," " )
    > > word = left(para,spacepos)
    > > Response.Write word 'this is the line I need to create a variable
    > > instead

    >
    > aVariable = aVariable & word
    >
    >
    >
    > > para = right(para,len(para)-spacepos)
    > > next

    >
    > > 'close the first words loop and print the remaining words in the first
    > > paragraph
    > > Response.Write "</span>" & para & "</p>" & vbcrlf

    >
    > > All this was designed to do it to is to take to take the first array
    > > item (a paragraph) and enclose the first words (in this case the first
    > > 4) in style tags. It works perfectly however, instead of "printing"
    > > the words with this line "Response.Write word", I need to instead
    > > place the words into a variable instead of just printing them, in
    > > other words, create a string of the first 4 words and place them into
    > > a variable like "firstWords" or whatever so I can call on it at a
    > > later time in the script. It should just be a simple thing but it's
    > > not turning out this way. I'd "really" appreciate ideas.

    >
    > > Thanks!!

    >
    > > John- Hide quoted text -

    >
    > - Show quoted text -


    Thanks. I tried this before...actually I tried it like this and it
    didn't work.

    firstWords = word & " " and firstWords 'need a space between each

    what am I missing?

    Thanks again!
     
    the other john, Apr 11, 2007
    #3
  4. "the other john" <> wrote in message
    news:...
    > On Apr 11, 10:55 am, "ThatsIT.net.au" <me@thatsit> wrote:
    >> "the other john" <> wrote in
    >> messagenews:...
    >>
    >> > This is a script someone here helped me with a while back and I am
    >> > very grateful for the help. I am stumped however as to how to change
    >> > it slightly.

    >>
    >> > This is the script...

    >>
    >> > storyArray = Split(myStory, vbcrlf & vbcrlf)
    >> > para = storyArray(0)

    >>
    >> > 'setup the loop for the first words here
    >> > Response.write "<p><span id='firstWords'>"

    >>
    >> dim aVariable
    >> aVariable = ""
    >>
    >> > for i = 1 to 4
    >> > spacepos = instr(para," " )
    >> > word = left(para,spacepos)
    >> > Response.Write word 'this is the line I need to create a variable
    >> > instead

    >>
    >> aVariable = aVariable & word
    >>
    >>
    >>
    >> > para = right(para,len(para)-spacepos)
    >> > next

    >>
    >> > 'close the first words loop and print the remaining words in the first
    >> > paragraph
    >> > Response.Write "</span>" & para & "</p>" & vbcrlf

    >>
    >> > All this was designed to do it to is to take to take the first array
    >> > item (a paragraph) and enclose the first words (in this case the first
    >> > 4) in style tags. It works perfectly however, instead of "printing"
    >> > the words with this line "Response.Write word", I need to instead
    >> > place the words into a variable instead of just printing them, in
    >> > other words, create a string of the first 4 words and place them into
    >> > a variable like "firstWords" or whatever so I can call on it at a
    >> > later time in the script. It should just be a simple thing but it's
    >> > not turning out this way. I'd "really" appreciate ideas.

    >>
    >> > Thanks!!

    >>
    >> > John- Hide quoted text -

    >>
    >> - Show quoted text -

    >
    > Thanks. I tried this before...actually I tried it like this and it
    > didn't work.
    >
    > firstWords = word & " " and firstWords 'need a space between each
    >
    > what am I missing?
    >
    > Thanks again!



    aVariable = aVariable & word & " "
     
    ThatsIT.net.au, Apr 15, 2007
    #4
  5. On Apr 15, 8:09 am, "ThatsIT.net.au" <me@thatsit> wrote:
    > "the other john" <> wrote in messagenews:...
    >
    >
    >
    >
    >
    > > On Apr 11, 10:55 am, "ThatsIT.net.au" <me@thatsit> wrote:
    > >> "the other john" <> wrote in
    > >> messagenews:...

    >
    > >> > This is a script someone here helped me with a while back and I am
    > >> > very grateful for the help. I am stumped however as to how to change
    > >> > it slightly.

    >
    > >> > This is the script...

    >
    > >> > storyArray = Split(myStory, vbcrlf & vbcrlf)
    > >> > para = storyArray(0)

    >
    > >> > 'setup the loop for the first words here
    > >> > Response.write "<p><span id='firstWords'>"

    >
    > >> dim aVariable
    > >> aVariable = ""

    >
    > >> > for i = 1 to 4
    > >> > spacepos = instr(para," " )
    > >> > word = left(para,spacepos)
    > >> > Response.Write word 'this is the line I need to create a variable
    > >> > instead

    >
    > >> aVariable = aVariable & word

    >
    > >> > para = right(para,len(para)-spacepos)
    > >> > next

    >
    > >> > 'close the first words loop and print the remaining words in the first
    > >> > paragraph
    > >> > Response.Write "</span>" & para & "</p>" & vbcrlf

    >
    > >> > All this was designed to do it to is to take to take the first array
    > >> > item (a paragraph) and enclose the first words (in this case the first
    > >> > 4) in style tags. It works perfectly however, instead of "printing"
    > >> > the words with this line "Response.Write word", I need to instead
    > >> > place the words into a variable instead of just printing them, in
    > >> > other words, create a string of the first 4 words and place them into
    > >> > a variable like "firstWords" or whatever so I can call on it at a
    > >> > later time in the script. It should just be a simple thing but it's
    > >> > not turning out this way. I'd "really" appreciate ideas.

    >
    > >> > Thanks!!

    >
    > >> > John- Hide quoted text -

    >
    > >> - Show quoted text -

    >
    > > Thanks. I tried this before...actually I tried it like this and it
    > > didn't work.

    >
    > > firstWords = word & " " and firstWords 'need a space between each

    >
    > > what am I missing?

    >
    > > Thanks again!

    >
    > aVariable = aVariable & word & " "- Hide quoted text -
    >
    > - Show quoted text -


    this was my solution....

    wordCount = rsStoryData("fld_order_firstWords")
    for i = 1 to wordCount
    spacepos = instr(para," " )
    word = left(para,spacepos)
    If i > 1 Then
    thisWord = thisWord & word
    Else
    thisWord = word
    End If
    para = right(para,len(para)-spacepos)
    next

    Thanks!
     
    the other john, Apr 17, 2007
    #5
  6. On Apr 17, 1:47 pm, the other john <> wrote:
    > On Apr 15, 8:09 am, "ThatsIT.net.au" <me@thatsit> wrote:
    >
    >
    >
    >
    >
    > > "the other john" <> wrote in messagenews:...

    >
    > > > On Apr 11, 10:55 am, "ThatsIT.net.au" <me@thatsit> wrote:
    > > >> "the other john" <> wrote in
    > > >> messagenews:...

    >
    > > >> > This is a script someone here helped me with a while back and I am
    > > >> > very grateful for the help. I am stumped however as to how to change
    > > >> > it slightly.

    >
    > > >> > This is the script...

    >
    > > >> > storyArray = Split(myStory, vbcrlf & vbcrlf)
    > > >> > para = storyArray(0)

    >
    > > >> > 'setup the loop for the first words here
    > > >> > Response.write "<p><span id='firstWords'>"

    >
    > > >> dim aVariable
    > > >> aVariable = ""

    >
    > > >> > for i = 1 to 4
    > > >> > spacepos = instr(para," " )
    > > >> > word = left(para,spacepos)
    > > >> > Response.Write word 'this is the line I need to create a variable
    > > >> > instead

    >
    > > >> aVariable = aVariable & word

    >
    > > >> > para = right(para,len(para)-spacepos)
    > > >> > next

    >
    > > >> > 'close the first words loop and print the remaining words in the first
    > > >> > paragraph
    > > >> > Response.Write "</span>" & para & "</p>" & vbcrlf

    >
    > > >> > All this was designed to do it to is to take to take the first array
    > > >> > item (a paragraph) and enclose the first words (in this case the first
    > > >> > 4) in style tags. It works perfectly however, instead of "printing"
    > > >> > the words with this line "Response.Write word", I need to instead
    > > >> > place the words into a variable instead of just printing them, in
    > > >> > other words, create a string of the first 4 words and place them into
    > > >> > a variable like "firstWords" or whatever so I can call on it at a
    > > >> > later time in the script. It should just be a simple thing but it's
    > > >> > not turning out this way. I'd "really" appreciate ideas.

    >
    > > >> > Thanks!!

    >
    > > >> > John- Hide quoted text -

    >
    > > >> - Show quoted text -

    >
    > > > Thanks. I tried this before...actually I tried it like this and it
    > > > didn't work.

    >
    > > > firstWords = word & " " and firstWords 'need a space between each

    >
    > > > what am I missing?

    >
    > > > Thanks again!

    >
    > > aVariable = aVariable & word & " "- Hide quoted text -

    >
    > > - Show quoted text -

    >
    > this was my solution....
    >
    > wordCount = rsStoryData("fld_order_firstWords")
    > for i = 1 to wordCount
    > spacepos = instr(para," " )
    > word = left(para,spacepos)
    > If i > 1 Then
    > thisWord = thisWord & word
    > Else
    > thisWord = word
    > End If
    > para = right(para,len(para)-spacepos)
    > next
    >
    > Thanks!- Hide quoted text -
    >
    > - Show quoted text -


    Oh, an incidentally, I didn't need to use vbcrlf for some reason.
    When I did it added a space making 2 spaces...strange. So, for
    reasons I can't explain, it creates it's own space. Got me why.
     
    the other john, Apr 17, 2007
    #6
  7. "the other john" <> wrote in message
    news:...
    > On Apr 15, 8:09 am, "ThatsIT.net.au" <me@thatsit> wrote:
    >> "the other john" <> wrote in
    >> messagenews:...
    >>
    >>
    >>
    >>
    >>
    >> > On Apr 11, 10:55 am, "ThatsIT.net.au" <me@thatsit> wrote:
    >> >> "the other john" <> wrote in
    >> >> messagenews:...

    >>
    >> >> > This is a script someone here helped me with a while back and I am
    >> >> > very grateful for the help. I am stumped however as to how to
    >> >> > change
    >> >> > it slightly.

    >>
    >> >> > This is the script...

    >>
    >> >> > storyArray = Split(myStory, vbcrlf & vbcrlf)
    >> >> > para = storyArray(0)

    >>
    >> >> > 'setup the loop for the first words here
    >> >> > Response.write "<p><span id='firstWords'>"

    >>
    >> >> dim aVariable
    >> >> aVariable = ""

    >>
    >> >> > for i = 1 to 4
    >> >> > spacepos = instr(para," " )
    >> >> > word = left(para,spacepos)
    >> >> > Response.Write word 'this is the line I need to create a variable
    >> >> > instead

    >>
    >> >> aVariable = aVariable & word

    >>
    >> >> > para = right(para,len(para)-spacepos)
    >> >> > next

    >>
    >> >> > 'close the first words loop and print the remaining words in the
    >> >> > first
    >> >> > paragraph
    >> >> > Response.Write "</span>" & para & "</p>" & vbcrlf

    >>
    >> >> > All this was designed to do it to is to take to take the first array
    >> >> > item (a paragraph) and enclose the first words (in this case the
    >> >> > first
    >> >> > 4) in style tags. It works perfectly however, instead of "printing"
    >> >> > the words with this line "Response.Write word", I need to instead
    >> >> > place the words into a variable instead of just printing them, in
    >> >> > other words, create a string of the first 4 words and place them
    >> >> > into
    >> >> > a variable like "firstWords" or whatever so I can call on it at a
    >> >> > later time in the script. It should just be a simple thing but it's
    >> >> > not turning out this way. I'd "really" appreciate ideas.

    >>
    >> >> > Thanks!!

    >>
    >> >> > John- Hide quoted text -

    >>
    >> >> - Show quoted text -

    >>
    >> > Thanks. I tried this before...actually I tried it like this and it
    >> > didn't work.

    >>
    >> > firstWords = word & " " and firstWords 'need a space between each

    >>
    >> > what am I missing?

    >>
    >> > Thanks again!

    >>
    >> aVariable = aVariable & word & " "- Hide quoted text -
    >>
    >> - Show quoted text -

    >
    > this was my solution....
    >


    'here lets create a string
    dim words

    ' here we load the P tag
    words = "<p>

    > wordCount = rsStoryData("fld_order_firstWords")
    > for i = 1 to wordCount
    > spacepos = instr(para," " )
    > word = left(para,spacepos)
    > If i > 1 Then


    'If you want the first words this should be
    If i < 5 Then


    > thisWord = thisWord & word


    ' here you need somthing like

    words = words & "<span id='firstWords'>" & word & "</span>"& " "


    > Else
    > thisWord = word & " "


    'and here

    words = words & word

    > End If
    > para = right(para,len(para)-spacepos)
    > next
    >



    'here end with

    words = words & "</p>"



    > Thanks!



    the above code would work, but creating large string in ASP slows things
    down
    Using a array would be better


    wordCount = rsStoryData("fld_order_firstWords")

    dim words()

    for i = 1 to wordCount
    spacepos = instr(para," " )
    word = left(para,spacepos)

    redim preserve words(i)

    If i < 5 Then
    words(i-1) = "<span id='firstWords'>" & word & "</span>"
    Else
    words(i-1) = word
    End If
    para = right(para,len(para)-spacepos)
    next


    Now write back

    respaonse.write "<p>"

    for each thing in words
    respaonse.write thing & " "
    next

    respaonse.write "</p>"
     
    ThatsIT.net.au, Apr 19, 2007
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Maziar Aflatoun
    Replies:
    1
    Views:
    495
    =?Utf-8?B?UGF1bA==?=
    Jan 22, 2005
  2. Andrew Francis
    Replies:
    0
    Views:
    426
    Andrew Francis
    Jun 28, 2006
  3. =?Utf-8?B?Y2FzaGRlc2ttYWM=?=

    Solution file not in the solution folder

    =?Utf-8?B?Y2FzaGRlc2ttYWM=?=, Sep 12, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    1,113
    Laurent Bugnion
    Sep 12, 2006
  4. , India
    Replies:
    17
    Views:
    1,066
    James Kanze
    Oct 1, 2007
  5. Replies:
    8
    Views:
    513
Loading...

Share This Page