Professional Web Applications Themes

get my head round this loop prob +ASP - Dreamweaver AppDev

Hi, I have a recordset loop which has a nested loop, which checks the value against an array of postcodes.. incrementing a counter by one when it finds a match.. However I also need to increment a counter when it doesn't find a match... the problem is however, that obviously whilst this sub-loop is going, it is constantly finding no match so my "nomatch" figure is totally incorrect.. Instead of adding one when the only thing left is that there isn't a match, it is obviously adding one everytime it doesn't find a match which isn't what I need.. I ...

  1. #1

    Default get my head round this loop prob +ASP

    Hi,
    I have a recordset loop which has a nested loop, which checks the value
    against an array of postcodes.. incrementing a counter by one when it finds
    a match..

    However I also need to increment a counter when it doesn't find a match...

    the problem is however, that obviously whilst this sub-loop is going, it is
    constantly finding no match so my "nomatch" figure is totally incorrect..

    Instead of adding one when the only thing left is that there isn't a match,
    it is obviously adding one everytime it doesn't find a match which isn't
    what I need..

    I know it's prob something to do with stopping the loop, or setting a var to
    True.. but can't get my head round what I should do:

    Example:
    171 records:

    Results:
    Scotland: 9
    Wales: 8
    North East: 115
    North West: 10
    Midlands: 7
    Anglia: 3
    South West: 2
    South Central: 4
    SouthEast: 4
    London:
    Other: 20187

    See? the Other one is adding loads of counts cos, whilst the sub-loop is
    happening, is adding one everytime,... I don't want this...

    Here#s my code:

    <%
    For strChart3_i = 1 to arr_PostcodeCount
    If strChart3PostcodeValue = arr_PostcodeCheck(strChart3_i) then

    If strChart3_i <= 17 then
    strChart3_Scotland = strChart3_Scotland + 1
    elseif strChart3_i >17 AND strChart3_i <= 23 then

    strChart3_Wales = strChart3_Wales + 1
    elseif strChart3_i >23 AND strChart3_i <= 39 then

    strChart3_NorthEast = strChart3_NorthEast + 1
    elseif strChart3_i >39 AND strChart3_i <= 54 then

    strChart3_NorthWest = strChart3_NorthWest + 1
    elseif strChart3_i >54 AND strChart3_i <= 64 then

    strChart3_Midlands = strChart3_Midlands + 1
    elseif strChart3_i >64 AND strChart3_i <= 79 then

    strChart3_Anglia = strChart3_Anglia + 1
    elseif strChart3_i >79 AND strChart3_i <= 91 then

    strChart3_SouthWest = strChart3_SouthWest + 1
    elseif strChart3_i >91 AND strChart3_i <= 102 then

    strChart3_SouthCentral = strChart3_SouthCentral + 1
    elseif strChart3_i >103 AND strChart3_i <= 113 then

    strChart3_SouthEast = strChart3_SouthEast + 1
    elseif strChart3_i >113 AND strChart3_i <= 119 then

    strChart3_London = strChart3_London + 1
    end if

    else
    strChart3_Other = strChart3_Other + 1
    end if

    Next
    %>


    Any ideas?

    Cheers
    James


    Jamesy Guest

  2. #2

    Default Re: get my head round this loop prob +ASP

    ignore - all done..

    James

    "Jamesy" <NOSPAMpatchworkmedia.co.uk> wrote in message
    news:d4svvc$mbh$1forums.macromedia.com...
    > Hi,
    > I have a recordset loop which has a nested loop, which checks the value
    > against an array of postcodes.. incrementing a counter by one when it
    > finds a match..
    >
    > However I also need to increment a counter when it doesn't find a match...
    >
    > the problem is however, that obviously whilst this sub-loop is going, it
    > is constantly finding no match so my "nomatch" figure is totally
    > incorrect..
    >
    > Instead of adding one when the only thing left is that there isn't a
    > match, it is obviously adding one everytime it doesn't find a match which
    > isn't what I need..
    >
    > I know it's prob something to do with stopping the loop, or setting a var
    > to True.. but can't get my head round what I should do:
    >
    > Example:
    > 171 records:
    >
    > Results:
    > Scotland: 9
    > Wales: 8
    > North East: 115
    > North West: 10
    > Midlands: 7
    > Anglia: 3
    > South West: 2
    > South Central: 4
    > SouthEast: 4
    > London:
    > Other: 20187
    >
    > See? the Other one is adding loads of counts cos, whilst the sub-loop is
    > happening, is adding one everytime,... I don't want this...
    >
    > Here#s my code:
    >
    > <%
    > For strChart3_i = 1 to arr_PostcodeCount
    > If strChart3PostcodeValue = arr_PostcodeCheck(strChart3_i) then
    >
    > If strChart3_i <= 17 then
    > strChart3_Scotland = strChart3_Scotland + 1
    > elseif strChart3_i >17 AND strChart3_i <= 23 then
    >
    > strChart3_Wales = strChart3_Wales + 1
    > elseif strChart3_i >23 AND strChart3_i <= 39 then
    >
    > strChart3_NorthEast = strChart3_NorthEast + 1
    > elseif strChart3_i >39 AND strChart3_i <= 54 then
    >
    > strChart3_NorthWest = strChart3_NorthWest + 1
    > elseif strChart3_i >54 AND strChart3_i <= 64 then
    >
    > strChart3_Midlands = strChart3_Midlands + 1
    > elseif strChart3_i >64 AND strChart3_i <= 79 then
    >
    > strChart3_Anglia = strChart3_Anglia + 1
    > elseif strChart3_i >79 AND strChart3_i <= 91 then
    >
    > strChart3_SouthWest = strChart3_SouthWest + 1
    > elseif strChart3_i >91 AND strChart3_i <= 102 then
    >
    > strChart3_SouthCentral = strChart3_SouthCentral + 1
    > elseif strChart3_i >103 AND strChart3_i <= 113 then
    >
    > strChart3_SouthEast = strChart3_SouthEast + 1
    > elseif strChart3_i >113 AND strChart3_i <= 119 then
    >
    > strChart3_London = strChart3_London + 1
    > end if
    >
    > else
    > strChart3_Other = strChart3_Other + 1
    > end if
    >
    > Next
    > %>
    >
    >
    > Any ideas?
    >
    > Cheers
    > James
    >

    Jamesy Guest

Similar Threads

  1. infinite loop error... Braking my head
    By Alejandro Ramos in forum Macromedia Flash Actionscript
    Replies: 11
    Last Post: February 4th, 02:54 PM
  2. #24876 [NEW]: Round does not round properly
    By jeff at tmtrading dot com in forum PHP Development
    Replies: 0
    Last Post: July 30th, 11:57 PM
  3. #24828 [Asn->Csd]: round() function doesn't round !
    By edink@php.net in forum PHP Development
    Replies: 0
    Last Post: July 28th, 10:08 PM
  4. #24828 [Opn->Asn]: round() function doesn't round !
    By iliaa@php.net in forum PHP Development
    Replies: 0
    Last Post: July 27th, 06:25 PM
  5. #24828 [NEW]: round() function doesn't round !
    By christophe dot bidaux at netcourrier dot com in forum PHP Development
    Replies: 0
    Last Post: July 27th, 11:34 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