| We hope you enjoy your visit. You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free. Join our community! If you're already a member please log in to your account to access all of our features: |
| Assist; In dis | |
|---|---|
| Tweet Topic Started: Dec 30 2004, 12:58 PM (513 Views) | |
| purge.exe | Dec 30 2004, 12:58 PM Post #1 |
|
Member
![]() ![]() ![]() ![]() ![]() ![]()
|
OK, that solved, but now the function doesn't do anything when I run it. ![]() Help me, purge.exe |
![]() |
|
| Dennis | Dec 30 2004, 02:24 PM Post #2 |
|
Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Why is there two )'s? |
![]() |
|
| Rory | Dec 30 2004, 02:27 PM Post #3 |
|
i;m a mess
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
one closes the IF condition, the other closes the paramater of .match |
![]() |
|
| purge.exe | Dec 30 2004, 02:55 PM Post #4 |
|
Member
![]() ![]() ![]() ![]() ![]() ![]()
|
New error, read first post. Help is appreciated, purge.exe |
![]() |
|
| Sithtradmus | Dec 30 2004, 06:30 PM Post #5 |
|
Member
![]() ![]() ![]()
|
Maybe you should remove the two '))' and see what happens. |
![]() |
|
| FearKiller | Dec 30 2004, 07:38 PM Post #6 |
|
www.drewscripts.com
![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
I don't know what the problem is, but I know that isn't it. |
![]() |
|
| purge.exe | Dec 30 2004, 07:46 PM Post #7 |
|
Member
![]() ![]() ![]() ![]() ![]() ![]()
|
I fixed it, but there's a new error. It doesn't do a thing, no matter what is passed to the function. Help... me..., purge.exe |
![]() |
|
| Gogf | Dec 31 2004, 09:23 PM Post #8 |
|
Indescribable
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
What exactly is it supposed to do? |
![]() |
|
| Seth | Dec 31 2004, 09:48 PM Post #9 |
|
I has a pony
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
It would help if you used descriptive variable names
|
![]() |
|
| purge.exe | Dec 31 2004, 10:52 PM Post #10 |
|
Member
![]() ![]() ![]() ![]() ![]() ![]()
|
Sorry about that. Here's a list of variables and their uses: from - What you want replaced to - What you want it replaced with varia - The string to replace from to to z - What to replace the string @i@ with (don't worry about this one) en_d - The stuff after from in varia ec_s - The loop variable. I use this because (for some reason), varia.indexOf(from) does not work co_u - Used to stop the loop from going further than it can. from cannot be found in a string that is smaller than it, so that's what this is used for, in other words Line-by-line walkthrough: to = to.replace("@i@", z); - Don't worry about this part if(varia.match(from)) // It's in the text - If it is found, do the calculations for(ec_s = 0; ec_s < co_u; ec_s++) - Keep looking for from in varia (same as indexOf, although indexOf DOESN'T WORK FOR SOME DAMN REASON) if(varia.substring(ec_s, (ec_s + from.length)).match(from)) - Have we found from? en_d = varia.substring(ec_s + from.length, varia.length); - Cut the data after where from was found and put it in en_d varia = varia.substring(0, ec_s); - Cut out the (first) from in varia // Debug purposes - Show me was the variables are right now varia = varia + to + en_d; - Replace the text break; - I forgot this line of code :$ Don't go any further, as we only want to replace the first one return varia; - Return the replacement (if there was one) Is that enough for yeh?, purge.exe |
![]() |
|
| SilverSky | Jan 2 2005, 06:04 PM Post #11 |
|
Member
![]() ![]() ![]()
|
I think I can see what you are trying to do* and you don't need to create a function. If you use the string replace method combined with a regular expression with a global flag then it should accomplish what you are trying to do... Examples:
|
![]() |
|
| 1 user reading this topic (1 Guest and 0 Anonymous) | |
| « Previous Topic · Technology Chat · Next Topic » |
| Track Topic · E-mail Topic |
8:55 PM Jul 10
|



![]](http://b1.ifrm.com/0/1/0/p601690/pipright.png)





8:55 PM Jul 10