ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old August 7th, 2003, 02:58 PM
unatratnag unatratnag is offline
Average Intelligence
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2003
Location: Ohio/Chicago
Posts: 678 unatratnag User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 22 sec
Reputation Power: 6
Send a message via AIM to unatratnag
querystring and isarray help

This is really weird, No matter what, i get true for the is array function on a querystring variable, anyone have ideas?

Let's say I pass in "george michaels" or "george" both return true on the is array, yet the A(1) will error if you try and access it on a "george" split on space.


Code:
name = Cstr(mid(request.querystring("name"),2,(len(request.querystring("name"))-2)))
response.write name & "<br>"
Arr=split(name," ")
response.write Arr(0) & "<br>"
'response.write Arr(1) & "<br>"
response.write IsArray(Arr)
if isarray(Arr) then
	response.write "muliname<br>"
else
                Do something
End if


Does anyone have any clue or any advice at all?

Reply With Quote
  #2  
Old August 7th, 2003, 03:01 PM
unatratnag unatratnag is offline
Average Intelligence
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2003
Location: Ohio/Chicago
Posts: 678 unatratnag User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 22 sec
Reputation Power: 6
Send a message via AIM to unatratnag
alright, now i'm really freaked out, this is hardcoded in:

Code:
name = "george michaels"
Arr=split(name," ")
response.write IsArray(Arr)


name = "george"
Arr=split(name," ")
response.write IsArray(Arr)

Both output true....

Reply With Quote
  #3  
Old August 7th, 2003, 03:36 PM
Vlince Vlince is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Canada, Quebec, Montreal
Posts: 410 Vlince User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Well of course it outputs *TRUE*

You know why ???

Because if you read the docs for SPLIT() it says:

Returns a zero-based, one-dimensional array containing a specified number of substrings.


So :

name = "george michaels"

Arr = split(name," ") <---split() will return an array so Arr is an array

response.write IsArray(Arr) <--Will return TRUE because Arr is in fact an array

That's why!

Hope this helps!
Sincerely

Vlince

Reply With Quote
  #4  
Old August 7th, 2003, 03:42 PM
unatratnag unatratnag is offline
Average Intelligence
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2003
Location: Ohio/Chicago
Posts: 678 unatratnag User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 22 sec
Reputation Power: 6
Send a message via AIM to unatratnag
how would one find out if the split worked then?

I'm passing in a name whether it be first, last, or both, and i need to check to see if the split worked, I guess i'll have to use instr(name, " ")...

stupid split...

Reply With Quote
  #5  
Old August 7th, 2003, 03:51 PM
Vlince Vlince is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Canada, Quebec, Montreal
Posts: 410 Vlince User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
I'm sorry, I don't get it :-(

What do you mean by:
---BEGIN QUOTE
how would one find out if the split worked then?
---END QUOTE

You're the programmer so why are you using the Split() function in the first place? If your are then you must have a good reason for no?

Let me ask you this:

Will you *always* have the First Name and Last Name OR can it sometimes be *ONLY* the First Name OR *ONLY* the Last Name OR BOTH

One thing you can try is:

<%
Dim Arr

Arr = Split(Request.Form("Something"))(0)
Response.Write Arr

OR if you want the second element in the array do:
Arr = Split(Request.Form("Something"))(1)
Response.Write Arr


NOTICE the (0) and (1) part!

Hope this helps!
Sincerely

Vlince


%>

Reply With Quote
  #6  
Old August 7th, 2003, 04:10 PM
unatratnag unatratnag is offline
Average Intelligence
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2003
Location: Ohio/Chicago
Posts: 678 unatratnag User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 22 sec
Reputation Power: 6
Send a message via AIM to unatratnag
Can't say I've ever seen the split function be used the way you're using it, and can't find any documentation on it and it errors on me when i copy your code so i'm not sure what you're getting at.

sorry for being unclear. Yes I am the programmer and am quite aware of why I'm using the split function. Thanks for your help on the IsArray and split, i assumed the split returned a scalar variable if there was no splitting, but it's not as you stated which is why it's always true

first, last, or both names are passed in, i don't know which it will be, it's random, sometimes a person knows their first name, sometimes just the last, sometimes they know a little of each, it's a guess as to what they'll know really.

I have first and last names in a DB and have to parse the name if they give me "geo mi" then i have to search like '%geo%' in the first name field and '%mi%' in the last name field and return the results.

I have it solved by using that instr function i was telling you about.
Code:
B   = InStr(name," ")

It just returns 0, the space just doesn't exist in the string and i continue on my merry way, i'm sure you knew that but that's how i'm using it.

regaurds

Reply With Quote
  #7  
Old August 8th, 2003, 06:54 AM
Vlince Vlince is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Canada, Quebec, Montreal
Posts: 410 Vlince User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
You are right, using the Split() the way I'm using it isn't documented but it works here copy/paste this example:

<%
Dim str
str = "The dog is red"

Response.Write "-->" & Split(str, " ")(0) & "<--<br>"
Response.Write "-->" & Split(str, " ")(1) & "<--<br>"
Response.Write "-->" & Split(str, " ")(2) & "<--<br>"
Response.Write "-->" & Split(str, " ")(3) & "<--<hr>"
%>

The end result should display:
-->The<--
-->dog<--
-->is<--
-->red<--

Using the Split() the way I'm using it is a shortcut and returns *ONLY* the string I WANT.

Notice that IT DOES NOT return an array since I wanted element (0) for example, so it only returned the string placed a element (0)

Of course if you have a string such as str = "My cat"
and you ask for this:
Response.Write "-->" & Split(str, " ")(2) & "<--<hr>"

This will not work, in fact I think its going to give you an error message since you dont have an element (2) in that string str


Vlince

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > querystring and isarray help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway