Professional Web Applications Themes

Classic ASP String Manipulation - NOT .net - ASP.NET Web Services

Good Evening, I would like to insert a 5 letter word into a 100 letter string, but only 1 letter at a time, and each letter separated by 10 characters!!! :) Using Alpha characters only, no numbers or punctuation in either string. The first letter needs to use the DAY OF THE MONTH number as its insertion point... So the string HELLO would be inserted on the 15th day of the month as follows: H inserted after character 14 of the 100 letter string E inserted after character 24 of the 100 letter string L inserted after character 34 of ...

  1. #1

    Default Classic ASP String Manipulation - NOT .net

    Good Evening,

    I would like to insert a 5 letter word into a 100 letter string, but only 1
    letter at a time, and each letter separated by 10 characters!!! :) Using
    Alpha characters only, no numbers or punctuation in either string. The
    first letter needs to use the DAY OF THE MONTH number as its insertion
    point...

    So the string HELLO would be inserted on the 15th day of the month as
    follows:

    H inserted after character 14 of the 100 letter string
    E inserted after character 24 of the 100 letter string
    L inserted after character 34 of the 100 letter string
    L inserted after character 44 of the 100 letter string
    O inserted after character 54 of the 100 letter string

    The final string will therefore be 105 characters in length! It's to help
    design a children's maze puzzle on a fun and games web site.

    Thanks for your time,

    James.
    (PS - could not find any classic ASP groups, sorry)


    James Guest

  2. #2

    Default Re: Classic ASP String Manipulation - NOT .net

    I don't remember a whole lot about ASP... but i would guess something
    with the following pseudocode would work

    1. create character array of 105 characters
    1.1 initialize array of characters to all spaces (' ')
    2. get what day of month today is (ie 15, or 10, or 8)
    3. chararray[dayofmonth] = 'h'
    4. chararray[dayofmonth+10] = 'e'
    5. chararray[dayofmonth+20] = 'l'
    6. chararray[dayofmonth+30] = 'l'
    7. chararray[dayofmonth+40] = 'o'

    i think vb addresses arrays with () notation (so chararray(dayofmonth)
    = 'h'), and dayofmonth would be an integer value with whatever the
    current day is.

    Hope this helps you get started, if you need more help e-mail me at
    darrenkopp [at] gmail [dot] com and i will dig into some ol' ASP and
    refresh my brain.

    -Darren Kopp
    http://blog.secudocs.com

    Darren Guest

  3. #3

    Default Re: Classic ASP String Manipulation - NOT .net

    re: 

    Try posting to microsoft.public.inetserver.asp.general



    Juan T. Llibre, asp.net MVP
    aspnetfaq.com : http://www.aspnetfaq.com/
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ===================================
    "James" <com> wrote in message news:H9KIf.8372$news.blueyonder.co.uk... 


    Juan Guest

  4. #4

    Default Re: Classic ASP String Manipulation - NOT .net

    James wrote: 

    Should this be "character 24" of the original 100 letter string?
    Or character 24 of the new string formed in step 1?
    I will assume the former

    <snip> 

    As Juan said: microsoft.public.inetserver.asp.general

    Something like this:

    <html><body style="font-family:courier"></body></html>
    <%
    dim s, j,k
    for k = 0 to 9
    for j = 1 to 9
    s = s & j
    next
    s = s & "0"
    next
    Response.Write s & "<BR>"

    response.write newstring("HELLO", s)

    function newstring(insert, bigstring)
    dim start, i, tmp, offset
    start=day(date)
    tmp=left(bigstring,(start-1))
    bigstring = mid(bigstring,start)
    for i = 1 to len(insert)-1
    offset=10 * (i - 1)
    tmp= tmp & mid(insert,i,1) & _
    left(bigstring,9)
    bigstring = mid(bigstring,10)
    next
    newstring = tmp & bigstring
    end function
    %>

    HTH,
    Bob Barrows
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.


    Bob Guest

  5. #5

    Default Re: Classic ASP String Manipulation - NOT .net

    Bob Barrows [MVP] wrote: 
    >
    > Should this be "character 24" of the original 100 letter string?
    > Or character 24 of the new string formed in step 1?
    > I will assume the former
    >
    > <snip>[/ref]

    Since it uses an array, this may perform better:
    <html><body style="font-family:courier"></body></html>
    <%
    dim s, j,k
    for k = 0 to 9
    for j = 1 to 9
    s = s & j
    next
    s = s & "0"
    next
    Response.Write s & "<BR>"

    response.write InsString("HELLO", s)

    function InsString(insert,byval bigstring)
    dim arString(), i
    redim arString(2*len(insert))
    for i = 1 to len(insert)
    arString(2*i-1)=mid(insert,i,1)
    next
    dim start, offset
    start=day(date)
    arString(0)= left(bigstring,start-1)
    offset = 0
    for i = 2 to ubound(arString) - 2 step 2
    offset = 9*i\2 - 9
    arString(i) = mid(bigstring,start+offset,9)
    next
    arString(ubound(arString)) = mid(bigstring,start+offset +9)
    InsString=join(arString,"")
    end function
    %>

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.


    Bob Guest

  6. #6

    Default Re: Classic ASP String Manipulation - NOT .net

    I'm glad i just wrote some pseudocode :D... though i'm still not sure
    if my pseudocode is what you did or not... it's been a long day.

    -darren

    Darren Guest

  7. #7

    Default Re: Classic ASP String Manipulation - NOT .net

    Darren Kopp wrote: 
    No, it's a little different, but your post did give me the idea.
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.


    Bob Guest

Similar Threads

  1. String Manipulation - Easiest Way?
    By Nanwedar in forum Macromedia ColdFusion
    Replies: 5
    Last Post: February 24th, 04:01 PM
  2. Another String Manipulation Question
    By Bill in forum Coldfusion - Advanced Techniques
    Replies: 4
    Last Post: February 21st, 03:31 AM
  3. String manipulation
    By Jerry Preston in forum PERL Beginners
    Replies: 2
    Last Post: January 19th, 01:27 PM
  4. String Manipulation Before Posting to a Database
    By Steve G in forum ASP Database
    Replies: 2
    Last Post: January 15th, 09:28 PM
  5. String manipulation and category building.
    By Sean Williams in forum ASP
    Replies: 0
    Last Post: September 24th, 11:23 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139