Categories > TinyButStrong general >

Can I add arguments?

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: RwD
Date: 2006-03-22
Time: 10:19

Can I add arguments?

tbs supports calling class functions where the function needs no arguments. Is it not an idea to add a field like "args=[var.argument1],[var.argument2]" so that the function can be called with some values? Doesn't need to be fancy; you get a lot of functionality with just supporting string arguments alone...

I hop you like the idea ;)
By: RwD
Date: 2006-03-22
Time: 10:31

Re: Can I add arguments?

A possible use of this is an object I have that supplies all configuration parameters from a database, but only loads them when it predictes they will be used or when they are asked for. But to specify the exact parameter I need I need to be able to send a string like 'core.session.lifetime' which returns the number of seconds a session should stay valid for. Now this specific example will be predicted by the object and is very often already loaded (and needed). But I have less frequent settings like 'module.search.messages.excluded' that is used to display a message showing the user certain search terms they posted where not used to find results (because they are very common).
By: RwD
Date: 2006-03-23
Time: 14:51

Re: Can I add arguments?

Inside function meth_Locator_Replace(&$Txt,&$Loc,&$Value,$CheckSub) I have replaced
$x = call_user_func(array(&$Value,$x));
with
if (isset($Loc->PrmLst['args'])) {
    $parameters =  explode(',', $Loc->PrmLst['args']);
    $x = call_user_func_array(array(&$Value,$x), $parameters);
} else {
    $x = call_user_func(array(&$Value,$x));
}
I do not know how you would do / would have done this, but it is something that enables me to add arguments to function calls. Only string based, no variables. But perhaps you can help out on this or perhaps even implement it?
By: RwD
Date: 2006-10-14
Time: 13:02

Re: Can I add arguments?

Hi,

It was nice to see version 3 included my suggestion above. However, it is not perfect yet! consider what I try to do:
[var.vantage.getConfig(data.stylesheet.default)]
This will be impossible because the . is used as a separator! How do I solve this problem, or does this require a change in the template engine?

(I wasn't around for a while because I didn't use V3 yet. Now I'm trying to see if I can easily implement it... I do require to make a lot of changes though)
By: Skrol29
Date: 2006-10-14
Time: 20:45

Re: Can I add arguments?

Hi RwD,

Your problem would needs a change in the template, or a plug-in to support such feature in another way. But I d'ont think the engine should go so far. Because the need of having more structured tags brings to have a new programing language in the template side.
By: RwD
Date: 2006-10-15
Time: 15:27

Re: Can I add arguments?

But then, the template engine should not place restrictions on the data.. Right now I cannot just send any variable to the function this way. I still need to rely on the solution I mentioned above...
By: RwD
Date: 2006-10-15
Time: 15:28

Re: Can I add arguments?

Perhaps you can add something like it?
By: Skrol29
Date: 2006-10-15
Time: 18:15

Re: Can I add arguments?

Hi,

For this case, you need "." to be accepeted while it is a TBS subname separator.
But you could also need:
-  ";" which is a parameter separator,
- "[" or "]" which are tags delimitors,
- "'" which is the parameter's string value delimitor
- "(" which is the argument delimitor for methods.
Maybe the list is longer.

They are several other ways to get your coniguration values.
For example, you could use a onformat function:
[onload;onformat=f_getconfig;key='data.stylesheet.default']
...
function f_getconfig($FieldName,&$CurrVal,&$CurrPrm) {
  global $vantage;
  $CurrVal = $vantage->getConfig($CurrPrm['key']);
}

See also
  http://www.tinybutstrong.com/forum.php?msg_id=6502