[stringtemplate-interest] Passing values into templates

Zenaan Harkness zen at freedbms.net
Sat Apr 19 15:18:44 PDT 2008


On Sat, Apr 19, 2008 at 04:49:22PM +0100, Ben Hood wrote:
> At the moment I'm trying to pass in the result of a computation from  
> within a super template:
> 
> temp() ::= <<
> int next = .....
> if (next <ge()> 0x20 && next <le()> 0x2f) {
>          return <readBytes(length={ next - 0x20 })>;
> }
>  >>
> 
> with
> 
> ge() ::= ">="
> le() ::= "\<="
> 
> and
> 
> readBytes(length) ::= "<! This should be overriden by a subclass  
> template !>"
> 
> I'd like to be able to implement the readBytes(length) template in a  
> subtemplate that is specific to the target language.

So your sub-group has a line near the top that says something like:

group my-language-or-subgroup-name : super-group-name;

??

And then your sub-groups (one for each language), implement
readBytes(length)?

Then it should work.

I haven't used STGroup interfaces yet, so someone else would have to
comment on that.

If it's not running, perhaps your value being passed to readbytes is all
that needs to change (you do know you can't do any maths calculations in
ST yes (except for if/endif)?).

Eg:
   return <readBytes("length= next - 0x20")>;

Good luck
Zen

-- 
Homepage: www.SoulSound.net -- Free Australia: www.UPMART.org
Please respect the confidentiality of this email as sensibly warranted.


More information about the stringtemplate-interest mailing list