![](templates/Classic/images/spacer.gif) |
Qaiia Wanderer
Joined: 06 Apr 2007 Posts: 59
|
Posted: 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. |
|
|
![](templates/Classic/images/spacer.gif) |
Fang Xianfu GURU
![](images/avatars/1763170544a2093e7e85da.gif)
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: 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. |
|
|
![](templates/Classic/images/spacer.gif) |
Guinn Wizard
Joined: 03 Mar 2001 Posts: 1127 Location: London
|
Posted: 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... ;) |
|
|
![](templates/Classic/images/spacer.gif) |
Qaiia Wanderer
Joined: 06 Apr 2007 Posts: 59
|
Posted: 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. |
|
|
![](templates/Classic/images/spacer.gif) |
|
|