Go Back   CodingForums.com > :: Client side development > Flash & ActionScript > Adobe Flex

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-27-2009, 03:31 AM   PM User | #1
0o_o0
New Coder

 
Join Date: Feb 2009
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
0o_o0 is an unknown quantity at this point
prob in split and array process

anyone have ideas how to solve this question?

myText.text: 1)www 200 23feb
2)www 303 24march

how to split "www", "200" and "23feb" into one column each of them.
then, how to make sure this split process also occur at "www 303 24march" and so on..
0o_o0 is offline   Reply With Quote
Old 02-27-2009, 12:58 PM   PM User | #2
gnomeontherun
Senior Coder

 
gnomeontherun's Avatar
 
Join Date: Sep 2007
Location: Houston
Posts: 2,846
Thanks: 10
Thanked 238 Times in 229 Posts
gnomeontherun will become famous soon enoughgnomeontherun will become famous soon enough
Code:
var str:String = "www 200 23feb";
var results:Array = str.split(" ");
This puts the string pieces into an array, which can then be added to a table.
__________________
jeremy - gnomeontherun
Educated questions often get educated answers, and simple questions often get simple answers.
gnomeontherun is offline   Reply With Quote
Old 03-06-2009, 08:10 AM   PM User | #3
0o_o0
New Coder

 
Join Date: Feb 2009
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
0o_o0 is an unknown quantity at this point
yes.. thank you for reply,,
but, it only split at the first of the sentences...
how to make sure it also split at the next sentences also.. for example:
this is the text after uploaded to the system:

www 200 23feb
www 303 24march
www 200 23feb
www 303 27march
www 200 21feb
www 303 29march

i want the split process also occur at www 303 24march, www 200 23feb and so on automtically after click the button. my system only split at the first sentences..

hope u can help me..
thank you.
0o_o0 is offline   Reply With Quote
Old 03-06-2009, 09:34 AM   PM User | #4
gnomeontherun
Senior Coder

 
gnomeontherun's Avatar
 
Join Date: Sep 2007
Location: Houston
Posts: 2,846
Thanks: 10
Thanked 238 Times in 229 Posts
gnomeontherun will become famous soon enoughgnomeontherun will become famous soon enough
The you have to make a loop to parse them all. Something like this should parse them into a multidimensional array for you to access however you need to display.

Code:
var strings = new Array();
strings[0] = "www 200 23feb";
strings[1] = "www 303 24march";
strings[2] = "www 200 23feb";
strings[3] = "www 303 27march";
strings[4] = "www 200 21feb";
strings[5] = "www 303 29march";

for (i=0;i<=strings.length;i++)
{
results[i] = strings[i].split(" "); //Saves array in an array
}
__________________
jeremy - gnomeontherun
Educated questions often get educated answers, and simple questions often get simple answers.
gnomeontherun is offline   Reply With Quote
Old 03-11-2009, 02:29 AM   PM User | #5
0o_o0
New Coder

 
Join Date: Feb 2009
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
0o_o0 is an unknown quantity at this point
can u check my code?
at bold sentences have error and it says expecting semicolon before left bracket..
i dont know what to do?
through this code, is it split myText.text into several categories?

private function applicationCompleteHandler():void
{
var stringToSplit:String = myText.text;
var result[i]:Array = stringToSplit[i].split(" ");
var Split:LogReader = new LogReader();

for (i=0;i<=stringToSplit.length;i++)
{
Split.ip = result[0];
Split.date = result[3] + result[4];
Split.method = result[5];
Split.info = result[6] + result[7];
Split.url = result[8];
}

sourceArray.push(Split);
ac.refresh();


}

thank you.
0o_o0 is offline   Reply With Quote
Old 03-11-2009, 09:43 AM   PM User | #6
gnomeontherun
Senior Coder

 
gnomeontherun's Avatar
 
Join Date: Sep 2007
Location: Houston
Posts: 2,846
Thanks: 10
Thanked 238 Times in 229 Posts
gnomeontherun will become famous soon enoughgnomeontherun will become famous soon enough
You are using an array index identifier that doesn't exist (i).

Code:
private function applicationCompleteHandler():void
{
var stringToSplit:String = myText.text;
var result:Array = stringToSplit.split(" ");
var Split:LogReader = new LogReader();

for (i=0;i<=result.length;i++)
{
Split.ip = result[0];
Split.date = result[3] + result[4];
Split.method = result[5];
Split.info = result[6] + result[7];
Split.url = result[8];
}

sourceArray.push(Split);
ac.refresh();

}
I guess I don't understand what you are trying to do, except that this code doesn't seem to make sense to me. I made another change in the for loop, because otherwise it won't run correctly (.length is for number of entries in an array here). What format is the data really coming in as (exactly) and what do you want it to sort into?
__________________
jeremy - gnomeontherun
Educated questions often get educated answers, and simple questions often get simple answers.
gnomeontherun is offline   Reply With Quote
Old 03-12-2009, 01:48 AM   PM User | #7
0o_o0
New Coder

 
Join Date: Feb 2009
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
0o_o0 is an unknown quantity at this point
thank you for reply.
okey..
this is the example of text that need to be split into several categories after uploaded into the system:

0.50.143.237 - - [31/Oct/2008:11:09:24 +0800] "GET /login/login.php?op=logout HTTP/1.1" 302 3727 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.17) Gecko/20080829 Firefox/2.0.0.17"

60.50.143.237 - - [31/Oct/2008:11:09:24 +0800] "GET /login/login.php?msj=You%20Have%20Been%20Forced%20to%20Logout HTTP/1.1" 200 3766 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.17) Gecko/20080829 Firefox/2.0.0.17"

60.50.143.237 - - [31/Oct/2008:11:09:24 +0800] "GET /images/stylesheet.css HTTP/1.1" 200 1958 "http://www.bppk.gov.my/login/login.php?msj=You%20Have%20Been%20Forced%20to%20Logout" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.17) Gecko/20080829 Firefox/2.0.0.17"

60.50.143.237 - - [31/Oct/2008:11:09:24 +0800] "GET /images/bg_main.gif HTTP/1.1" 200 869 "http://www.bppk.gov.my/images/stylesheet.css" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.17) Gecko/20080829 Firefox/2.0.0.17"

usually the text is more longer than this..
the split divided only 5 categories:ip, date, method, info and url. that's why this code had been made:

var stringToSplit:String = myText.text;
var result:Array = stringToSplit.split(" ");
var Split:LogReader = new LogReader();
Split.ip = result[0];
Split.date = result[3] + result[4];
Split.method = result[5];
Split.info = result[6] + result[7];
Split.url = result[8];

and the package LogReader.as imported in the system made this process works.

my problem is how to make the split process also occur at the next ip address?
my coding only split at the first paragraph..
i want it split simultaneously at the whole paragraph at the text that had been uploaded into the system.
i hope my explanations is good enough to make u understand what is actually i am going to do..
i hope u can help me.
thank you.

Last edited by 0o_o0; 03-12-2009 at 02:12 AM..
0o_o0 is offline   Reply With Quote
Old 03-12-2009, 11:14 AM   PM User | #8
gnomeontherun
Senior Coder

 
gnomeontherun's Avatar
 
Join Date: Sep 2007
Location: Houston
Posts: 2,846
Thanks: 10
Thanked 238 Times in 229 Posts
gnomeontherun will become famous soon enoughgnomeontherun will become famous soon enough
So you are reading a log, that makes this more tricky. Honestly I would employ a few techniques rather than just splitting the string. You can search a string if it contains "POST" or "GET" for example, you could get the text between [] as the date, and search based on what is between " marks. It would be more labor intensive and require stronger code, but would be a much better way. What if someone has a URL with a space in it? You would have errors I think the current way.
__________________
jeremy - gnomeontherun
Educated questions often get educated answers, and simple questions often get simple answers.
gnomeontherun is offline   Reply With Quote
Old 03-13-2009, 03:03 AM   PM User | #9
0o_o0
New Coder

 
Join Date: Feb 2009
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
0o_o0 is an unknown quantity at this point
yes. but the other features will implemented after the split process works at the whole paragraph..
the system actually also planned to should be have check box option to make the analyzer more easier to analyze log.
as i told before, it works splitting at the first paragraph and it shows that split by space is not be the problem.. and let be my supervisor think it about if have space in the url because he asks me to do it like this. but, i will ask him later.
however, i have problem in how to make the splitting process also splitting at the second and so on paragraphs simultaneously with the first paragraph..
i had try this before:

for each(var line:String in myText.text.split("\n"))

but its wont work!

do you have any ideas?

thank you.
0o_o0 is offline   Reply With Quote
Old 03-13-2009, 10:45 AM   PM User | #10
gnomeontherun
Senior Coder

 
gnomeontherun's Avatar
 
Join Date: Sep 2007
Location: Houston
Posts: 2,846
Thanks: 10
Thanked 238 Times in 229 Posts
gnomeontherun will become famous soon enoughgnomeontherun will become famous soon enough
Two options, \r is actually the return character. the ascii code is also 13 for it.
Code:
myText.text.split(char(13));
myText.text.split("\r");
__________________
jeremy - gnomeontherun
Educated questions often get educated answers, and simple questions often get simple answers.
gnomeontherun is offline   Reply With Quote
Old 03-17-2009, 02:03 AM   PM User | #11
0o_o0
New Coder

 
Join Date: Feb 2009
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
0o_o0 is an unknown quantity at this point
i had try myText.text.split(char(13)) but have error..

#1180:call to a possibly undefined method char

how can i avoid this error?

and when i try myText.text.split("\r");
it still only split the first paragraph..

Last edited by 0o_o0; 03-17-2009 at 10:17 AM..
0o_o0 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:52 PM.


Advertisement
Log in to turn off these ads.