|
alluran Adept
Joined: 14 Sep 2005 Posts: 223 Location: Sydney, Australia
|
Posted: Fri Dec 22, 2006 11:19 am
Recursion Function Causes Hard Crash |
Ok, so this is probably a nasty piece of code to throw at a BETA release, but Almost all my scripts use this, or the ansi color version of this for their outputs (depends if its outputting to mud or screen)
Lets assume we make a variable (function, whatever, i tried using #func to create it too :P) named highlight with the following code
Code: |
%char( 64)%2%left( %item( %replace( %1, " ", "|"), %max( 1, %4)), 1)%char( 64)%if( %len( %3)>0, %3, %if( %2=%upper( %2), %lower( %2), %upper( %2)))%right( %item( %replace( %1, " ", "|"), %max( 1, %4)), 1)%if( %max( 1, %4)<%numitems( %replace( %1, " ", "|")), %char( 32)@highlight(%1,%2,%3,%eval(%max(1,%4)+1)))
|
now, #say @highlight(Test,R) works perfectly, however, as soon as you introduce spacing in (ie make it use its recursion routines) it will crash. So to test, simply go #say @highlight("Crash Now",R)
once again, cMud is looking nice, and the features list has me dreaming, just get the scripting up a little better and i'll leave zMud forever :) |
|
|
|
Ceres Wanderer
Joined: 25 May 2006 Posts: 88
|
Posted: Fri Dec 22, 2006 12:16 pm |
CMUD is not a BETA assuming you have the latest version 1.24
|
|
|
|
kjaerhus Magician
Joined: 18 Dec 2006 Posts: 317 Location: Denmark
|
Posted: Fri Dec 22, 2006 12:54 pm |
That is an obscure piece of scripting you have there - bet you could win a code obfuscation contest with it...
What is it supposed to do? Maybe that would make deciphering it a bit easier. |
|
|
|
alluran Adept
Joined: 14 Sep 2005 Posts: 223 Location: Sydney, Australia
|
Posted: Fri Dec 22, 2006 3:26 pm |
Meh, fine, its not the beta, i dunno, i only installed it the other day, i still use zmud primarily, had been waiting for cmud to become a little more stable, and yeah, its 1.24
Basically the script highlights the first letter of each word that you pass into it, my mud uses @<color> for colors, so for example, @highlight(This is a Test,R) would produce @RT@rhis @Ri@rs @Ra@r @RT@rest |
|
_________________ The Drake Forestseer |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Fri Dec 22, 2006 10:09 pm |
I think it is actually the recursive call that is causing the crash. In any case....
%subregex(%1,"(.?)(\a+\b?)","@R%1@r%2") |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
alluran Adept
Joined: 14 Sep 2005 Posts: 223 Location: Sydney, Australia
|
Posted: Fri Dec 22, 2006 10:32 pm |
Your subregex didnt work for me, though i think i know what you're getting at, guess its time i finally learnt regexp
|
|
_________________ The Drake Forestseer |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sat Dec 23, 2006 8:47 pm |
Well, you could just do it with an oninput trigger using Zugg's syntax if you'd rather.
|
|
|
|
NowhereMan Beginner
Joined: 09 Dec 2004 Posts: 10
|
Posted: Tue Dec 26, 2006 7:37 pm |
Vijilante wrote: |
%subregex(%1,"(.?)(\a+\b?)","@R%1@r%2") |
i think he probably meant \w, not \a .
afaik, \a doesn't match anything useful. (Alarm/beep?)
substituting \w for \a, that regex will also match a space followed by a word, so the spaces between the words will get colored rather than the first letter.
i think this slight modification will work for you:
%subregex(%1,"\b(\w)","@R%1@r")
fyi,
\b matches a 'word boundary', so this regex should capture any letter preceeded by something that's not part of a word (like a space, punctuation, or the beginning of the line). |
|
|
|
alluran Adept
Joined: 14 Sep 2005 Posts: 223 Location: Sydney, Australia
|
Posted: Tue Dec 26, 2006 8:31 pm |
i figured whats going on, and the news is all bad i'm afraid
i copied the example straight outta the documentation:
Code: |
#SHOW %subregex("100 gold, 200 silver", "(\d+)", "%eval(%1+10)") |
and it outputted
Quote: |
10 gold, 10 silver |
so it would seem, the subregex function is broken to me |
|
_________________ The Drake Forestseer |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed Jan 17, 2007 8:25 pm |
Added the %subregex example to the bug list.
For the recursive problem, I'll need a simpler example to really debug this. Recursive function calls will crash CMUD if they end up being infinite loops that never stop calling itself. |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Wed Jan 17, 2007 10:28 pm |
I remember reading in another thread that the recursive function example in the #function help file causes a crash.
|
|
|
|
Guinn Wizard
Joined: 03 Mar 2001 Posts: 1127 Location: London
|
|
_________________ CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;) |
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|