|
Author |
Topic: strange String behavior (Read 564 times) |
|
trip
|
strange String behavior
« on: Sep 4th, 2003, 8:41pm » |
|
Maybe I'm just missing something, but I am having a really odd problem: go to http://www.negativespace.org/cmendoza/files/why/whywhy.html and a silly animation appears. I am using an array of strings to generate the random numbers that grow. Now go to the source code and find the "problem area"... comment the current string, un-comment another string example and try to run it. Basically, when a String is equal to "4" P5 complains and doesn't run the applet. But when I replace "4" with anything else, the applet runs fine. Why c
|
|
|
|
flight404
|
Re: strange String behavior
« Reply #1 on: Sep 4th, 2003, 11:08pm » |
|
Well, in Japanese, the word for 'four' is the same as the word for 'death' but something tells me that has nothing to do with it.
|
|
|
|
fry
|
Re: strange String behavior
« Reply #2 on: Sep 5th, 2003, 12:20am » |
|
in processing, "4" means death for the crappy preprocessor. it mangles a four in quotes into something unintelligible. you could get around it by using any other way to generate a 4.. String four = String.valueOf(4); // sorry it's this complicated issue is the same as this feller: http://proce55ing.net/discourse/yabb/board_BugFixes_action_disp_lay_num_1062461664.html luckily it's been fixed and rev 60 will no longer have this trouble.
|
|
|
|
trip
|
Re: strange String behavior
« Reply #3 on: Sep 5th, 2003, 8:50am » |
|
on Sep 5th, 2003, 12:20am, fry wrote: String four = String.valueOf(4); // sorry it's this complicated |
| Actually, that is the kind of function I wanted to use anyway... since I'm no Java coder (I'm coming from Director) I couldn't figure out how to turn an int into a String. So thanks for the bug fix, and thanks again for telling me what I actually needed!! Is there a clear reference to Java on the net I'm sure there is one, but I can't seem to find it. thx c
|
|
|
|
benelek
|
Re: strange String behavior
« Reply #5 on: Sep 5th, 2003, 1:16pm » |
|
that's the full java reference alright, but it's sometimes as clear as mud. the parts you might want to look at, are those related to the commonly used classes (like String). they generally have a whole lot of useful little methods attached.
|
|
|
|
trip
|
Re: strange String behavior
« Reply #7 on: Sep 6th, 2003, 2:53am » |
|
thanks for the links guys i usually just search on java.sun.com as well, but it is hard to find what you want if you don't really know what you want i've been spoiled by Lingo's sweet and compact reference help file. c
|
|
|
|
Jerronimo
|
Re: strange String behavior
« Reply #8 on: Sep 6th, 2003, 4:56am » |
|
The "4" bug is totally fascinating to me. I'm curious as to what really was happening that caused that reaction from the engine.
|
|
|
|
fry
|
Re: strange String behavior
« Reply #9 on: Sep 8th, 2003, 11:27am » |
|
the preprocessor in the old version just used a more advanced version of search and replace using regular expressions (via a library called oro matcher, if you're curious about how that works). it substitutes in the various things we need to make p5 syntax into java syntax. but for code that's inside of comments, you don't to substitute anything inside of that, so the comments get scrambled just before the preprocessor runs, then they get unscrambled when it's done. so the bug comes when the scrambling/unscrambling hack winds up making a mess.
|
|
|
|
fry
|
Re: strange String behavior
« Reply #10 on: Sep 21st, 2003, 7:50pm » |
|
closing this off since it's fixed for 60 which will be online shortly.
|
|
|
|
|