splitting date with ASP
Hi there
I have a field in my database, where I store information, on user actions etc.
I have found out how to store the information, but now I need to know, how I get the information back, in the order I want!
Ok, the information is stored in 1 cell per user.
It looks like this:
cell =
information1,information2,information3;information1,information2,information3,information1,infor...
As you might have noticed, I have several sets of information in each cell.
Now I want the information, on an opther page, to be split up.
I know that I can use tyhe SPLIT()-tag, but I don't know it good enough.
Example on how I need it to look:
dim info1Array, info2Array, info3Array, totalinfoArray
totalinfoArray = split(DBcon("informa"), ";")
info1Array = split(totalinfoArray(0), ",")
'etc...
But I jut don't know how to make this all work!
You are probably just as confused as I am now, so I will try to write it in short terms now:
I want it to split up the cell, so that I have each information, in each seperat variable (array).
The number of information "sets" in each cell can be VERY different. (it is a multible user system, so it is just a template I need).
Then I need a third variable that states how many "sets" there actually is in the array. Meaning: I want a variable that has counted the number of Array Layers, like var beep = xxxArray.count
I hope that you understand my question... and I really hope that you can help me too!
Kind regards
~Casper Bang
Mark Hensler posted this at 22:24 — 11th January 2001.
He has: 4,048 posts
Joined: Aug 2000
are you a C programmer??
don't ask why I asked, just popped into my mind when I read your post..
another question, why have you used one cell per user?
and why have you put soo much info in that cell?
(it's just asking for a headache)
moving on.....
you did get the Split() syntax correct
as for the number of elements in an array, use UBound(array_name)
you may want something like this:
totalinfoArray = split(DBcon("informa"), ";")
count = 0
for i=0 to UBound(totalinfoArray)
infoArray(i) = split(totalinfoArray(i), ",")
next
your info would look like this in the arrays:
given in DB:
text1,text2,text3;text4,text5,text6;text7,text8,text9;text10,text11,text12;
in arrays:
+-----------+--------+--------+--------+
| infoArray | (x)(0) | (x)(1) | (x)(2) |
| (0)(x) | text1 | text2 | text3 |
| (1)(x) | text4 | text5 | text6 |
| (2)(x) | text7 | text8 | text9 |
| (3)(x) | text10 | text11 | text12 |
+-----------+--------+--------+--------+
so...
infoArray(0)(0) = "text1"
infoArray(0)(1) = "text2"
infoArray(2)(2) = "text9"
(just read it like that grid in algebra and geometry, cartesan plain or however its spelled)
(for the table above, UBound(infoArray) will return 3, LBound(infoArray) will return 0)
If I didn't get your question right, just strangle the guy next to you then ask again. Good Luck,
Mark Hensler
If there is no answer on Google, then there is no question.
hotcut posted this at 13:36 — 12th January 2001.
They have: 133 posts
Joined: Sep 2000
I think that you have helped me out again Max! Thanks for that!
To ansver some of YOUR questions:
are you a C programmer??
Do you mean if I program C++?
in the next question you ask me why I only have 1 cell per user. I have more than 12 by now, but this one will be having some special data, which will be of very different size per user.
I am programming an online game ( http://www.secretsofwar.vze.com )so I need to store all information regarding attacks in a database cell. Due to that it is different how much attack info there is on each person, I will need to store the info on a single cell, in order to make it work - I THINK
And... I don't want to make too many cells... Right now there is only 47 players, and the databse allready have a size of more than 5 megabyte...
Back to subj.
I think that you have given me the information I need for now, but I might need some more help later... Keep an eye on this thread
Kind regards
~Casper Bang
hotcut posted this at 16:00 — 12th January 2001.
They have: 133 posts
Joined: Sep 2000
Hi
I can't get it to work!
When I try to run the code, it says that the types mismath!
Here is the code I am using:
dim infoArray, i, totalinfoArray
totalinfoArray = split(rsRecordSet("attacklog"), ";")
for i=0 to UBound(totalinfoArray)
infoArray(i) = split(totalinfoArray(i), ",") 'it is in this line it tells me that there is an error
next
for i=0 to UBound(totalinfoArray)
'I am writing out the code here.
next
Do you see any problem with this? The contents of the cell I am getting the data from is:
factory,0,0,0,29,9,lost,hotcut;
Thats it...
I really hope that you can help me with this!
Regards
~Casper
Mark Hensler posted this at 18:47 — 12th January 2001.
He has: 4,048 posts
Joined: Aug 2000
Whatever version of C (C, C++, C#)....
What kind of game is it? I couldn't find any info on the site.
Well, I'm sure about anything right now, because I have no access to a NT server right now. But I'll take a stab at it.
the problem I see is the 'Dim' statement. I don't think that ASP is seeing infoArray as a multi-dimension array [array(1)(2)].
Solutions:
'Dim' it larger than necessary. Like infoArray(100)( [or ideally: infoArray(num_players)(num_stats_per_semicolon)]
OR
Find another way to store the info when we pull it out of the DB
OR
Re-design the DB (messy, but I could reduce size... let me know if you wanna do that)
Let's try the first one. I'm not sure how ASP will handle vars like this in a 'dim' statement, but lets try anyway...
Num_Stats = 8 'numerb of stats per semi-colon
Num_Players = rsRecordSet.RecordCount
dim infoArray(Num_Players)(Num_Stats)
dim i, totalinfoArray
totalinfoArray = split(rsRecordSet("attacklog"), ";")
for i=0 to UBound(totalinfoArray)
infoArray(i) = split(totalinfoArray(i), ",")
next
for i=0 to UBound(totalinfoArray)
'I am writing out the code here.
next
Did you strangle the guy next to you?
Mark Hensler
If there is no answer on Google, then there is no question.
hotcut posted this at 10:02 — 13th January 2001.
They have: 133 posts
Joined: Sep 2000
I works!
Thanks a lot!
No, I don't program C#, I only program in ASP, and script in javascript...
The game is a game a little like Cashwars, just WAY more advanced, and more fun ;=)
When the game gets up and runnning, you will be abel to win money, and steal them from other people playing the game! (without risk offcourse) I think that its gonna be cool!
~Casper
Yea, the guy next to me is dead... real messy though, I wouldn't like to clean him off my boots...
hotcut posted this at 10:07 — 13th January 2001.
They have: 133 posts
Joined: Sep 2000
How do I find out the servers date/time? I will need to put that into the database too...
I think that it should be an easy server variable, so it shoudln't be hard to do.
Thanks in advance
~Casper
Secrets Of War:
http://www.secretsofwar.vze.com
if server down:
www15.brinkster.com/secretsofwar
Mark Hensler posted this at 15:59 — 13th January 2001.
He has: 4,048 posts
Joined: Aug 2000
WHEW!! ....it works.
date/time.... now()
hotcut posted this at 16:09 — 13th January 2001.
They have: 133 posts
Joined: Sep 2000
Thanks, found out!
~Casper
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.