Wednesday, January 26, 2005

well, today I begun learning how to use processing. A program I usually avoid (due to the fact you need to code stuff), however so far I've found it quite nice and friendly... ish, but whats a few OutOfMemory messages between friends.

So far Ive managed to get it to read my log file, ignore the crap, turn the strings into numbers and put them all in a lovely array of usable floats (in order of course).

Heres the code. And please please, if anyone can do this more efficiently I'd love to know how, cuz I'm sure I shouldnt be doing this the way I have (theres probably a rediculously simple way).


size (200,200);

String intarr [] = loadStrings("UT2004.log");
int len = intarr.length;
String justnum [] = new String [len];


for (int i=0; i < len; i++) {

String temp[] =splitStrings(intarr[i]);
justnum[i] = temp[3];

}

String formatted = join(justnum, " ");
float thelist[] = splitFloats(formatted);

println(thelist[100]); //just checking


God I hate code, I mean its not exactly pretty to look at is it! Anyway there it is so far, and as for my lego animation... well, lets call that "on hold" shall we (this is far more exciting).

By the way I keep putting my code on here incase for some reason I should lose the working version, At least I know the good working stuff exists here. and also just incase someone else needs the same thing done as me (this thingy up here for example I'm sure will be useful to someone).

Oh yeah thanks RegularX on the beyondunreal forums, most helpful :)

3 Comments:

Blogger Rob Lycett said...

You'll get to like it. I thought your code looked OK [but the acid test is getting it past the king of OOP, our very own Si]. I wrote some simple Processing sketch today to put commas after every digit in a 1,000 digit number, to make an array. It's just a tool, not magic.

10:36 pm  
Blogger Quasimondo said...

Just a tiny optimization, which in this case is probably not worth it (depends on the length of your log file), but it might come handy on other occasions:

Replace the line:

for (int i=0; i < len; i++) {

with:

for (int i=len; --i >=0;) {

I'm looking forward to what you will be doing with processing.

1:43 am  
Blogger Alison said...

Thanks quasimondo, I'll do that. :)

2:28 am  

Post a Comment

<< Home