
strings string and strings
hi all<BR>I have a string of numbers like this "129012451267"<BR>here I have to check if the first two numbers of every four numbers are equal or not, In this case they are. i.e, 12<BR>so I need the o/p as that number(here its 12)<BR><BR>In another string like "129300341287" here they are not, <BR>i.e, we have 12 00 12, where we have one another number(12) and 00, So I need the o/p as the major number. In this case its 12<BR><BR>In another string like "129345346587" here we have three different numbers 12 45 65, so I need the o/p XX<BR><BR>One another thing is the string can be of any 4 digit length , like 4,8,12,16 ....digits long.<BR><BR>Its like U can see it and tell the answer, but how do i code it in ASP using VBScript<BR><BR>hope to hear from u <BR>thx<BR>

Answer these first...
So what do you do with<BR><BR>"1200340012113411"<BR>???<BR><BR>Here, 12 and 34 each appear twice. So which one "wins"???<BR><BR>When you say you need the output XX for the three different numbers, do you mean *LITERALLY* "XX" ??<BR><BR>Any other boundary conditions you didn't tell us about? Suppose we get<BR><BR>120034005600121134111299<BR><BR>12 is there 3 times<BR>34 twice<BR>56 once<BR><BR>Does 12 "win" in that case?<BR><BR>By the way, if you can type in a string like "129345346587" how come you can't type in "output"?? Or "you"?<BR><BR>(C...1 uv my pp's w/ ng pstgs.)<BR><BR>

RE: Answer these first...
So what do you do with "1200340012113411" ??? <BR>Here, 12 and 34 each appear twice. So which one "wins"??? <BR>)D8 is the output<BR><BR>When you say you need the output XX for the three different numbers, do you mean *LITERALLY* "XX" ?? <BR>)I actually need D8<BR><BR>Any other boundary conditions you didn't tell us about? Suppose we get 120034005600121134111299 12 is there 3 times 34 twice <BR>56 once <BR>Does 12 "win" in that case? <BR>) In this case the output is D8 because 12 34 and 56 are all different.<BR>It can be any one number(12 OR 34 OR 56) and 00 only, then the ans is that number , beccause its greater than 00<BR><BR>I'll give it to u as the need is<BR> If the string comes from only one row, the header byte(the first 2 chars of every four chars is the header byte)<BR> is the upper byte(the two chars we need) of the chars<BR> IF the string comes from only one row other than row 00, but also has chars only from row 00, the header byte is the upper byte of the chars from the non 00 row<BR> Else its D8<BR>eg:0023 1234 0012<BR>here in 0023, 00 is the header byte of 0023<BR>12 is the header byte of 1234<BR>00 is the header byte of 0012<BR>so our output should be 12 because its the header byte of the non zero row(every 4 numbers correspond to one row, we have 3 entries, 2 from 00 row and one from 12 row)<BR>hope this helps

Whew...weird...
Okay...I'll try...<BR><BR><%<BR>Function GetFlag( str ) ' str is your funny string<BR> If Len(str) < 4 OR ( Len(str) MOD 4 ) <> 0 Then<BR> ' bad length for string!<BR> GetFlag = "D8"<BR> Exit Function<BR> End If<BR><BR> result = 0 ' initialize result<BR> For n = 1 To Len(str) Step 4 ' 4 characters at at time...<BR> curnum = CInt( Mid( str, n, 2 ) ) ' but get just 2 digits as a number<BR> If curnum > 0 Then ' replace 0 result...<BR> If result > 0 Then<BR> ' two nonzero values...error? D8 is code?<BR> GetFlag = "D8"<BR> Exit Function<BR> End If<BR> ' if here, this is the first num > 0<BR> result = curnum<BR> End If<BR> Next<BR> GetFlag = Right( "00" & result, 2 )<BR>End Function<BR>%><BR><BR>

weird, I know..
bill thx for the reply ,But I haven't got my solution<BR>but I always get the ans as D8....<BR><BR>even If I use the string "1234 1299 1265"(given spaces for easyness)<BR>I should have got 12 here, becos 12 is the only row here..<BR><BR>if I use "1234 0099 1265"<BR>I should again get 12 , becos it is from only one row(12) and row 00 . so I should get the output as 12 because its the upper header of the non zero row(every 4 numbers correspond to one row)<BR><BR>if I use "123460994365<BR>then I should get D8 because its from more than one row and therz no 00 row

Bill wilkinson do u know the final solution?
Bill wilkinson do u know the final solution?

Oh...you didn't give that example!
Easy to fix:<BR><BR>Just change this line:<BR> If result > 0 Then <BR>to this: <BR> If result > 0 AND result <> curnum Then <BR><BR>See why? Before, it rejected on finding a nonzero number if it already had found *any* nonzero number. Now it rejects only if the nonzero number does not match the one it had previously found.<BR><BR>Dirt simple. I bet you could have found this one if you'd looked at my logic closer.<BR><BR>
Posting Permissions
 You may not post new threads
 You may not post replies
 You may not post attachments
 You may not edit your posts

Forum Rules

