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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
Derar
Novice


Joined: 09 Sep 2006
Posts: 44

PostPosted: Tue Aug 10, 2010 2:27 pm   

[3.22a] Feature Request - Dynamic Function Call
 
Would be nice if the following parsed out successfully:

Code:

$func = "_TestFunc"
#CALL @{$func}($arg1, $arg2)


Similar to how this works:
Code:

$var = "TestVar"
$var2 = @{$var}


You can sort of hash together something really ugly with #EXEC and %concat, but... it's messy and it gets weird when you start to try to include db vars as parameters.

Example:
Code:

$func = "_TestFunc"
#EXEC {%concat("#CALL @", $func, "(", $arg1, ", ", $arg2, ", ", $arg3, ")")}


You can also make it work pretty much fine with an alias instead of a function, but would be nice to have an easy way to call it dynamically as a function.

Alternatively, if somebody's got an idea on how I can do that now... :)
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Tue Aug 10, 2010 4:00 pm   
 
I think that's actually a bug. It parses and compiles but generates slightly wrong compiled code. So I'll add this to the bug list.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Wed Aug 18, 2010 8:42 pm   
 
Looks like this works if the function is a inline variable function, like this:
Code:
  <alias name="doit" id="3">
    <value>$func="testvar"
#show @{$func}(1,3)</value>
  </alias>
  <var name="testvar" id="5">%eval(%1+%2)</var>

however, if doesn't work when it's a real function, like this:
Code:
  <alias name="doit" id="3">
    <value>$func="test"
#show @{$func}(1,3)</value>
  </alias>
  <func name="test" id="4">
    <value>#RESULT %eval(%1+%2)</value>
  </func>


In any case, should be fixed in the next version.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum 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