|
Arminas Wizard
Joined: 11 Jul 2002 Posts: 1265 Location: USA
|
Posted: Sun Nov 12, 2006 4:34 am
[1.15] #if statements don't like User defined functions |
I decided to start using set and get alias/functions to access variables and set up these respectively.
#alias varset {#var %1 %2 _nodef {Vars}}
#variable varget {~%eval( ~%concat( "@Vars/", ~%1))}
And so I found another bug
When I use varget in an if the setting will not compile.
#if (@varget(thing1)="1") {do this} {do that}
Error compiling script:
unmatched parenthesis
But if I do this.
#if (%eval(@varget(thing1))="1") {do this} {do that}
It compiles nicely. |
|
_________________ Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sun Nov 12, 2006 5:13 am |
Very strange. I had it working when I typed it in myself, but it doesn't work at all when using your example. And now I can't get it to work again. It compiles fine up until the point where you're adding the outcomes to the #if command - the expression part works until then.
Regardless, a couple of things you could change (assuming we manage to get it working) is to remove the unecessary ="1" from the #if and change the %1 in varget to a local variable. |
|
|
|
Arminas Wizard
Joined: 11 Jul 2002 Posts: 1265 Location: USA
|
Posted: Sun Nov 12, 2006 5:34 am |
Thanks, I know about using the local variables just not the syntax for using them in a creation statement. I don't usually type in my settings into the command prompt. I'm a gui weeny as far as Zmud and Cmud go.
And, I actually do need the ="1" when I manage to get it to work at all in cMud It is being treated like a string. Also I could have decided to use something like "Right", "Left", "Yellow, or "No" in the value of my variable.
It is true that in this example I am trying to test for boolean and it would be nice if it were being treated appropriately, unfortunately it is not.
Finally, The point of the post IS that #IF statements don't like it |
|
_________________ Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Sun Nov 12, 2006 5:44 am |
Yeah, and it's really annoying me. I had it working for a minute or two with settings I'd typed myself, and then when I copied and pasted yours it stopped working. Now I can't reproduce the original set that worked. Anything I try stays bugged.
|
|
|
|
Arminas Wizard
Joined: 11 Jul 2002 Posts: 1265 Location: USA
|
|
_________________ Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Mon Nov 13, 2006 8:19 pm |
Well, I talked about using #FUNCTION instead of #VAR to create functions, but I still reproduced the problem with #IF with this simple example:
#function add {%eval(%1+1)}
#if (@add(1) = 2) {true} {false}
So I've added this to the bug list. |
|
|
|
|
|