 |
charneus Wizard

Joined: 19 Jun 2005 Posts: 1876 Location: California
|
Posted: Tue Jun 08, 2010 3:03 am
[3.18d]BUG: Quotes showing up in this function |
Before this version, the output would read something like:
38 s
(with color codes in it, indicated by the @r and @R values).
Now, it returns
38 ""s
(with same color codes, but note the "" in it as well...)
Code: |
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
<func name="TrackerTimeFormatOne" copy="yes">
<value>#RETURN %if( %eval( %1/86400)>0, %eval( %1/86400)"@r"d"@R ")%if( %eval( %1/3600)>0, %eval( ( %1/3600)-%eval( ( %1/86400)*24))"@r"h"@R ")%if( %eval( %1/60)>0, %eval( (%1/60)-((%1/3600)*60))"@r"m"@R ")%eval( %1-%eval( ( %1/60)*60))"@r"s</value>
</func>
</cmud>
|
Not sure what the problem is, as creating a function to do:
#RETURN "@r"%1"@R"
works perfectly. I'm wondering if it's the %if portion...
Charneus |
|
|
 |
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Tue Jun 08, 2010 1:06 pm |
I think this has to do with this change:
Quote: |
No longer strips " quotes within {} quotes in scripts |
I've noticed the same thing. Apparently it is not stripping quotes whenever implicit concatenation is used. |
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Tue Jun 08, 2010 4:40 pm |
Yes, it seems to be implicit concat. I may be re-thinking this change about not stripping the quotes again.
But in your above script, why is the "d" and "h" and "m" and "s" outside the quotes. Can you try doing:
Code: |
#RETURN %if( %eval( %1/86400)>0, %eval( %1/86400)"@rd@R ")%if( %eval( %1/3600)>0, %eval( ( %1/3600)-%eval( ( %1/86400)*24))"@rh@R ")%if( %eval( %1/60)>0, %eval( (%1/60)-((%1/3600)*60))"@rm@R ")%eval( %1-%eval( ( %1/60)*60))"@rs" |
and see if that works? |
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Tue Jun 08, 2010 5:05 pm |
Btw, I think you can also get rid of most of the %eval calls in the above script too. In CMUD, you should always think twice before using %eval. Each use of %eval causes the entire compiler to be executed at run time. In your above script, you are causing the compiler to run several times each time you use your function, which will make it very slow.
You might be better off getting rid of %eval and using proper %concat to clean up this script, make it faster, more reliable and easier to support in the future.
Certainly the first argument of %if doesn't need %eval if you just put () around the entire argument, just like when using #IF. For example:
Code: |
%if( ((%1/86400)>0), ... |
works just fine in all cases. For your other %evals, using %concat with () to indicate evaluation works like this:
Code: |
%concat( (%1/86400), "@rd@R") |
|
|
|
 |
|
|
|
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
|
|