Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Qaiia
Wanderer


Joined: 06 Apr 2007
Posts: 59

PostPosted: Mon Nov 12, 2007 11:00 pm   

dec2bin function - zmud => cmud 1.34
 
Code:
#FUNC dec2bin {%if("%1"!="0",%concat(@dec2bin(%eval(%1/2)),%mod(%1,2)))}


This bit of script, which I used in a more complex script in zmud, causes an infinite loop when converted to cmud. Anyone have a tip on converting this into a real function?

TIA.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Mon Nov 12, 2007 11:05 pm   
 
Try running the compatability report. You have %1 quoted, which means it's comparing the literal string "%1" to the literal string "0" (I can't remember off the top of my head whether CMUD coerces strings into numbers). But regardless, since "%1" will never equal "0", it keeps calling itself over and over.

Also, CMUD 2.x has "real" functions with proper returns. You might find them more useful for doing this sort of thing once it's gone public.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Mon Nov 12, 2007 11:38 pm   
 
Yep, Fang's right about the "%1"="0" bit causing problems, just remove it and I also changed %eval to %int just because it seemed sensible. The one below works fine

%if(%1!=0,%concat(@dec2bin(%int(%1/2)),%mod(%1,2)))
_________________
CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;)
Reply with quote
Qaiia
Wanderer


Joined: 06 Apr 2007
Posts: 59

PostPosted: Tue Nov 13, 2007 12:32 am   
 
This worked wonderfully, thank you.

Now I have to find out why Cmud's not squelching the gsl.
_________________
Citrus: The Juicy Alternative
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
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

© 2009 Zugg Software. Hosted by Wolfpaw.net