Code Bank
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingCode Bank

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 ASP Free Forums Sponsor:
  #1  
Old February 18th, 2005, 03:03 AM
lokisapocalypse lokisapocalypse is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 24 lokisapocalypse User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 41 m 47 sec
Reputation Power: 0
Split()

Hey guys,

I am having some trouble with the standard Split function. What happens is that I have read data in from a file to a 2D array. But the first element of row in that array needs to be split. So here's what I have:

Code:
  
   Dim hackArray
   Dim hackString
 
   For i=1 to numEntries
 	hackString = finalFileData(0,i)
 	hackArray = Split(hackString)
 	Response.Write(UBound(hackArray) & "<br>")
 	if(UBound(hackArray) = 2) Then
 	  Response.Write("here<br>")
 	  finalFileData(sizeDatabase-1, i-1) = hackArray(0)
 	  finalFileData(0, i) = hackArray(1)
 	end if
   Next


numEntries is the number of entries in the 2D array
I am trying to split by spaces. I tried printing out the UBound of hackArray each time and every time it read 0. I thought it should at least read 1?

Anyways, any ideas why this is happening and what I can do to fix it?

Reply With Quote
  #2  
Old February 18th, 2005, 03:11 AM
nofriends's Avatar
nofriends nofriends is offline
Senior Water Wizard
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Aug 2004
Location: Cape Town, RSA
Posts: 10,186 nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 107805 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107805 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107805 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107805 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107805 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107805 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 2 Weeks 2 Days 7 h 36 m 24 sec
Reputation Power: 699
Hi,

you must specify in you split function what you want to split by
Code:
 hackArray = Split(hackString)
 to
 hackArray = Split(hackString," ")
 


hope this helps
__________________
Look! Its a ShemZilla



Reply With Quote
  #3  
Old February 21st, 2005, 01:40 AM
lokisapocalypse lokisapocalypse is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 24 lokisapocalypse User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 41 m 47 sec
Reputation Power: 0
Quote:
Originally Posted by nofriends
Hi,

you must specify in you split function what you want to split by
Code:
   hackArray = Split(hackString)
   to
   hackArray = Split(hackString," ")
   


hope this helps


That's not the problem unfortunately. By default, ASP will split on the space. So adding that in gives me the same problem.

What I am trying to split is:
Generation 578502689

by the space.

When I do this:
Code:
	
 hackString = finalFileData(0,i)
 hackArray = Split(hackString," ")

it does not split (that is what is in that array, Generation 578502689.

But when I do this,
Code:
	
 hackArray = Split("Generation 578502689"," ")

it splits fine.

Any other ideas?

Last edited by lokisapocalypse : February 21st, 2005 at 01:42 AM. Reason: Mistyped

Reply With Quote
  #4  
Old February 21st, 2005, 02:02 AM
nofriends's Avatar
nofriends nofriends is offline
Senior Water Wizard
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Aug 2004
Location: Cape Town, RSA
Posts: 10,186 nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 107805 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107805 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107805 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107805 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107805 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107805 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 2 Weeks 2 Days 7 h 36 m 24 sec
Reputation Power: 699
Hi,

what happens when you response.write

Code:
 hackString = finalFileData(0,i)
 response.write hackString


just want to make sure that hackString is storing the correct value before we move on

Reply With Quote
  #5  
Old February 21st, 2005, 02:15 AM
lokisapocalypse lokisapocalypse is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 24 lokisapocalypse User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 41 m 47 sec
Reputation Power: 0
It writes:

Generation 578502689

Also of interest, when I do this:

Code:
  hackString = finalFileData(0,i)
 	hackArray = Split(hackString," ")
 	Response.Write(UBound(hackArray) & "<br>")


it prints out a bunch of 0's. (this code is contained in a loop.) But I don't think having it in a loop is the problem because it doesn't work the first time anyway.

Reply With Quote
  #6  
Old February 21st, 2005, 02:32 AM
nofriends's Avatar
nofriends nofriends is offline
Senior Water Wizard
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Aug 2004
Location: Cape Town, RSA
Posts: 10,186 nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 107805 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107805 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107805 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107805 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107805 Folding Title: Super Ultimate Folder - Level 1Folding Points: 107805 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 2 Weeks 2 Days 7 h 36 m 24 sec
Reputation Power: 699
hi,

i am not sure what is going wrong here,
have a feeling it has something to do with you array's

Code:
For i=1 to numEntries
be
For i=0 to numEntries


shouldn't you start at 0 for your array?

Have pm'ed some of the senior members to have a look

Reply With Quote
  #7  
Old February 21st, 2005, 02:34 AM
lokisapocalypse lokisapocalypse is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 24 lokisapocalypse User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 41 m 47 sec
Reputation Power: 0
Thank you for having some of the senior members take a look. Starting the array at 1 is intentional. What happens is that there are 83 fields (0 to 82). What is in column one needs to be split and the first element needs to be in space 82 and the second element needs to be in space 0 of the next record. It starts at 1 because the 0th element in the 0th record is correct and does not need to be split.

Reply With Quote
  #8  
Old February 21st, 2005, 04:47 AM
Lafinboy's Avatar
Lafinboy Lafinboy is offline
The Laughing Moderator
ASP Free Loyal (3000 - 3499 posts)
 
Join Date: Apr 2004
Location: Sydney, Australia
Posts: 3,267 Lafinboy User rank is Sergeant (500 - 2000 Reputation Level)Lafinboy User rank is Sergeant (500 - 2000 Reputation Level)Lafinboy User rank is Sergeant (500 - 2000 Reputation Level)Lafinboy User rank is Sergeant (500 - 2000 Reputation Level)Lafinboy User rank is Sergeant (500 - 2000 Reputation Level)  Folding Points: 29199 Folding Title: Starter FolderFolding Points: 29199 Folding Title: Starter Folder
Time spent in forums: 2 Weeks 1 Day 10 h 48 m 12 sec
Reputation Power: 15
Send a message via ICQ to Lafinboy Send a message via AIM to Lafinboy Send a message via MSN to Lafinboy Send a message via Yahoo to Lafinboy Send a message via Skype to Lafinboy
Does indeed sound like an array declaration/measurement problem.

What is the value of numentries and how is it determined? If your original 2d array is of the format (0,n), where n is an arbitry number, then using uBound to measure the number of items will return 0, which will obviosly mess with further calculations if you are expecting to get n as the result.

Reply With Quote
  #9  
Old February 21st, 2005, 05:59 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 46th Plane (27500 - 27999 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 27,737 Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)  Folding Points: 377762 Folding Title: Super Ultimate Folder - Level 1Folding Points: 377762 Folding Title: Super Ultimate Folder - Level 1Folding Points: 377762 Folding Title: Super Ultimate Folder - Level 1Folding Points: 377762 Folding Title: Super Ultimate Folder - Level 1Folding Points: 377762 Folding Title: Super Ultimate Folder - Level 1Folding Points: 377762 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 2 Weeks 5 h 41 m 46 sec
Reputation Power: 1914
sounds like that blank space is not blank space. to discover what is that character, have such code:
Code:
Function StrToAscii(str)
 	Dim result, x
 	result=""
 	For x=1 To Len(str)
 	   result=result&Asc(Mid(str, x, 1))
 	   If x<Len(str) Then
 		  result=result&" "
 	   End If
 	Next
 	StrToAscii=result
  End Function
    
    Dim hackArray
    Dim hackString
    
    For i=1 to numEntries
   	hackString = finalFileData(0,i)
   	'''lines below are for debugging only, remove when all is working!
   	Response.Write("hackString raw: "&hackString&"<br />")
   	Response.Write("hackString ascii: "&StrToAscii(hackString)&"<br />")
   	'''---------------------------------
   	hackArray = Split(hackString)
   	 Response.Write(UBound(hackArray) & "<br>")
   	 if(UBound(hackArray) = 2) Then
   	   Response.Write("here<br>")
   	   finalFileData(sizeDatabase-1, i-1) = hackArray(0)
   	   finalFileData(0, i) = hackArray(1)
   	 end if
      Next
   

you can also copy&paste the string directly into this tool:
http://www.amitbb.co.il/General_Stu.../StrToAscii.asp

Last edited by Shadow Wizard : February 22nd, 2005 at 03:11 AM. Reason: fixed the function :/

Reply With Quote
  #10  
Old February 22nd, 2005, 01:13 AM
lokisapocalypse lokisapocalypse is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 24 lokisapocalypse User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 41 m 47 sec
Reputation Power: 0
Shadow Wizard, I tried the ToAscii function and this is what I get:

Quote:

hackString raw: Generation 578502689
hackString ascii:


In other words, the hackString ascii prints nothing. I tried to copy and paste the Generation 578502689 to that link you posted but it gave me normal ASCII tabs and when I copied and pasted that into a regular string, it would split just fine.

Reply With Quote
  #11  
Old February 22nd, 2005, 01:17 AM
lokisapocalypse lokisapocalypse is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 24 lokisapocalypse User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 41 m 47 sec
Reputation Power: 0
Quote:
Originally Posted by Lafinboy
What is the value of numentries and how is it determined?


numentries is = numElements / (sizeDatabase-1)

numElements = Ubound(filedata) where filedata is the original textfile parsed by '|'. Now I can't use this to parse the entire thing because the last column of each record is not separated by | and that is why I need to do the split function. So in other words, "Generation 578502689" should be Generation as the last element of the previous record and 578502689 should be the first element on the current record.

sizeDatabase = 83 because 83 is the number of columns in this database.

I divide by sizeDatabase - 1 instead of sizeDatabase because the last column does not get parsed correctly and so I skip over that entry for now but the split (when it works) will populate that last column.

Reply With Quote
  #12  
Old February 22nd, 2005, 03:12 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 46th Plane (27500 - 27999 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 27,737 Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)  Folding Points: 377762 Folding Title: Super Ultimate Folder - Level 1Folding Points: 377762 Folding Title: Super Ultimate Folder - Level 1Folding Points: 377762 Folding Title: Super Ultimate Folder - Level 1Folding Points: 377762 Folding Title: Super Ultimate Folder - Level 1Folding Points: 377762 Folding Title: Super Ultimate Folder - Level 1Folding Points: 377762 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 2 Weeks 5 h 41 m 46 sec
Reputation Power: 1914
Quote:
Originally Posted by lokisapocalypse
Shadow Wizard, I tried the ToAscii function and this is what I get:



In other words, the hackString ascii prints nothing. I tried to copy and paste the Generation 578502689 to that link you posted but it gave me normal ASCII tabs and when I copied and pasted that into a regular string, it would split just fine.

oops... my mistake sorry. got nasty bug in that function, Edited my post and fixed that now. take the new StrToAscii function and try again, you would see the true ascii values.

Reply With Quote