![]() |
String trouble
1 Attachment(s)
I'm trying my own MAKI script (first one ever), which displays a string in the song title place or whatever its name (the same one as TitleClock), so I created some functions to help me. If you see the code below, I call my own stringReplace function to change some strings to values but it seems all the strings are converted to only one value, the integerToLongTime(getTimeOfDay()) one. Bizarre? Definitely. Try it out yourselves. Attached is the complete script.
|
I haven't waded my way through that one function (the one called by textparse) but your whole character by character compare isn't working. and its a horribly inefficent way to do things. I played with rewriting your function for a few minutes and got something that worked although not all that well or completely. however, it didn't hang on the first one. try commenting out that first line (that replaces the time and it will replace all of them with the next one)
You should look in to using the strSearch function. Using that to break the string in to three parts, the begining, the middle (the part to be replaced) and the end. then you can compare the middle part however you want. all though if(middle == from) does seem to have a certain draw. You might also want not just call the same function for each one. but rather search until strsearch returns a NULL (i think it will if it doesn't find anything.) this way, doing it the way i suggested would allow you to have one tag in there more than once. (although you method tries to do this now, it doesn't work) |
Strsearch returns -1 if it doesn't find anything. Other than that, everything HollowEarth said is correct.....I've got about a 90% working function, just have to track down one strange case where the from text is replaced twice, although the rest of the line is correct.
-=Gonzotek=- |
Alright, thanks a bundle. But then again, the main question didn't get answered, even if it's inefficient and stuff, why would the code assign from to something and then not change it? Compiler bug or something? And why's it inefficient?
Thanks for the help then, the winamp guys should provide a str_replace function (as in PHP) or something similar, that would kick someone's ass |
Alright, so I tried
code: And it crashes. Any ideas? |
code: The problem I'm encountering with this (and my version, which is messier) is that when something to be replaced is at the very end of the input string, somehow some characters from the middle of the string are shoved on to the end....and I can't trace out why...maybe you can? Other than that, it seems to be working pretty well. -=Gonzotek=- |
why not just use strsearch?
code: |
| All times are GMT. The time now is 11:09. |
Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.